aspose file tools*
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
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: 10916
    
  12

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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: boolean return question
 
Similar Threads
short circuit operators question
Is there a better way to do this method...?
Dan's Mock Exam Q - Operators and Precedence
Conditional Operators
Operator Precedence