posted 16 years ago
Boolean b1=true;
Boolean b2=false;
Boolean b3=true;
if((b1=false)|(b1&b3)|(b1|b2))
System.out.println("beta");
Here first of all this will be executed.
(b1=false)
This is because expressions are evaluated from left to right
so b1 will become false. Since this will result in a boolean value so there will be no compile time error.
So the first value will be false
Then (b1&b3) will be evaluated. Since b1 is false so it will result in false.
Then (b1|b2) will be evalued. Since both b1 and b2 are false, so this will result in false.
So at last the whole condition will becode
false|false|false
which will result in false so beta will not be displayed.
Also your code has declarations Boolean and not boolean. Although this will work but I just want to remind you...
[ August 08, 2008: Message edited by: Ankit Garg ]