File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Operator Question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Operator Question" Watch "Operator Question" New topic

Operator Question

Ali Khan

Joined: Sep 27, 2005
Posts: 18
I was wondering what the OR operation is in Java. I know that the AND operation is && and just need to know the Or. I used to know it from c++ but have forgotten =(
Mark Van Tuyl
Ranch Hand

Joined: Mar 22, 2002
Posts: 60
The OR operator is ||

<a href="" target="_blank" rel="nofollow">How To Ask Smart Questions</a>
Layne Lund
Ranch Hand

Joined: Dec 06, 2001
Posts: 3061
Both Java and C++ have two AND operators and two OR operators. && and || are the most commonly used because they typically appear in boolean expressions. & and | are usually used for bitwise manipulation, but can be used in boolean expressions as well. However, the behavior is slightly different because && and || "shortcut" the evaluation of the right operand depending on the value of the left one. You can search these forums or google for "shortcut operators" to find out more about this.


Java API Documentation
The Java Tutorial
I agree. Here's the link:
subject: Operator Question
jQuery in Action, 3rd edition