+ 2
What this a || b is used for???
i aM sOo confused to know about this!!
13 Answers
+ 4
It means a or b, "||" is the operator
+ 3
It is one of the logical operator whose two operands should be expressions.
If any one of the two operand's expression is true, the output will be true.
Example:
int a=0, b=5;
boolean result = (a>2) || (b==5)
then result will be true.
The same is applicable for more than two operands also
+ 2
it is or operator used for comparision
+ 1
it is an operator "||". it is short form of or.
+ 1
If you are comparing values with each other your answer will be true or false.
If you have an boolean value (0=false / 1=true) and compare it to another, you will receive an answer depending on your comparison.
Example:
boolean a = true, b = true, c = false;
boolean d;
d = a&&b; // True
d = a&&c; // False
d = a || c; // True
On an AND compare you need both input values true.
But on an OR compare you need just one of them.
You can go on and compare even bytes with each other.
Example:
Byte a = 23; // 0001 0111
Byte b = 44; // 0010 1010
Byte c = a && b // 0000 0010 = 2
Byte d = a || b // 0011 1111 = 63
But be careful. The MSB (most-significant-bit) is the sign.
0111 1111 = 127
1000 0000 = -128
1000 0001 = -127
...
1111 1111 = -1
In this case we are talking about an overflow.
+ 1
'||' is the logical 'OR' operator.
For example 'a||b' means 'whether a OR b' . ie., either a or b are true.
0
thnkio
0
|| is OR operator
If any of the condition is True the expression will be true.
0
It's logical operator. if one of them condition is true it will execute. if both condition true it will execute also. if both are not true then it will go to next statement/condition.
0
This mean A or B, and if you want to have A and B you can use && .
Have a good day
0
|| is or
&& is and
0
|| is OR operator and there is also | operator
- 1
it means a or b