Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Operator Question

 
Ali Khan
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI,
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
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The OR operator is ||
 
Layne Lund
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

Layne
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic