aspose file tools
The moose likes Beginning Java and the fly likes boolean return question Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "boolean return question" Watch "boolean return question" New topic
Author

boolean return question

Quang Pham
Ranch Hand

Joined: Nov 29, 2005
Posts: 47
Hi
Can some one explain the following code:

boolean a = false;
boolean b = false;
boolean c = false;

public boolean isOptionValid(){
return a||b||c;
}

Thanks
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 10040
    
    6

the || operator means "shortcut logical OR". do you know your boolean logic rules?

a OR b OR c

since in this case all three are false, the result is false, so false is returned.


Never ascribe to malice that which can be adequately explained by stupidity.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: boolean return question
 
Similar Threads
Operator Precedence
short circuit operators question
Is there a better way to do this method...?
Dan's Mock Exam Q - Operators and Precedence
Conditional Operators