This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv 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 REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "boolean return question" Watch "boolean return question" New topic

boolean return question

Quang Pham
Ranch Hand

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

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

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

fred rosenberger
lowercase baba

Joined: Oct 02, 2003
Posts: 11923

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
subject: boolean return question
It's not a secret anymore!