Boolean expressions in Java -


I have a question about the meaning of the Boolean variable in return statements in Java.

I know that:

  if (var) {...}  

is the same:

  if (var == true) {...}  

In the second case we explicitly say var ==, but we do not have to do this Is because Java evaluates the var as well anyway. I hope that I have understood this right.

My question is this: Is this the same when the Boolean variables are returned? When we have a return statement?

For example, a task specifies: The method looks like a better () only when the B & lt; a. My solution was:

  Public boolean looks better () {if (b & lt; a) {true; } Other {return false; }}  

The simple answer was:

  public boolean look (beta) {return b < a; }  

Therefore, it seems that here again we have the assumption that in the case of B & L; A == True, the return of the law is true. I am sorry ... it seems very trivial, but I am not comfortable with it anyhow, and I do not know why it is thanks.

This is not a "underlying assumption," what is this compiler doing b < A is just an expression, similarly if it is used for a if statement, expression evaluates a boolean , which then returns .

In addition to this, you can type boolean and Boolean as they are, but they are not actually boolean a form While the boolean is the one that wraps the boolean


Comments