Back to question Answer 1 of 1

Discuss MackTheKnife's answer to: How to use || in java?

The || symbol in java and in all the C family or programming languages is used to signify "or" in a condition.

For example you want to invoke a particular method if either one of 2 condition occurs. So you would type:

if(condition 1 || condition 2).

If either of these condition is upheld then the method would be invoked.

In contrast, you have the && which is used to symbolise "and"

so you would have:

if(condition 1 && condition 2)

the method would be invoked only if both of these conditions is upheld. If one of them is not then the method would not be invoked.

"The time has come" the walrus said "to speak of many things. Of shoes and ships and sealing wax. Of cabbages and kings. And why the sea is boiling hot and whether pigs have wings."
Liked this answer? Tell your friends about it
Add Your Comment (or add your own answer)
Insert: