This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes boolean return question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
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: 11153
    
  16

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.


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
 
wood burning stoves
 
subject: boolean return question
 
Similar Threads
Is there a better way to do this method...?
Dan's Mock Exam Q - Operators and Precedence
Conditional Operators
short circuit operators question
Operator Precedence