TICS Coding Standard Viewer 
TIOBE Software Quality Framework
Print-friendly version
©TIOBE Software www.tiobe.com
 
TIOBE - Java Coding Standard
Search

Rule:  Design2Checked automatically with code checker

Synopsis:Avoid unnecessary if..then..else statements when returning a boolean
Language:Java
Severity Level:4
Category:Design


Description:
Avoid unnecessary if..then..else statements when returning a boolean.
public class Foo {
  private int bar =2;
  public boolean isBarEqualsTo(int x) {
    // this bit of code
    if (bar == x) {
     return true;
    } else {
     return false;
    }
    // can be replaced with a simple
    // return bar == x;
  }
}