title: Boolean expressions in Java
body: <p>I have a question about the meaning (evaluation) of Boolean variables in return statements in Java.</p>
  
  <p>I know that:</p>
  
  <pre><code>if (var) { ... }
  </code></pre>
  
  <p>is the same as:</p>
  
  <pre><code>if (var==true) { ... }
  </code></pre>
  
  <p>In the second case we explicitly say var==true, but we don't need to do this, because Java evaluates var as true anyway. I hope I have understood this right.</p>
  
  <p>My question is: is it the same when Boolean variables are returned? When we have a return statement?</p>
  
  <p>For example, a task specifies: the method looksBetter() will return true only if b &lt; a. My solution was:</p>
  
  <pre><code>public boolean looksBetter() {
       if (b &lt; a) {
           return true;
       } else {
           return false;
       }
  }
  </code></pre>
  
  <p>The simple answer was:</p>
  
  <pre><code>public boolean lookBetter() {
        return b &lt; a;
  }
  </code></pre>
  
  <p>So, it seems that here we have again this implicit assumption that in case b &lt; a == true, the return of the method is true.
  I am sorry ... it seems very trivial, but I am somehow not comfortable with this, and I don't know why. Thank you.</p>