code: class T { public static void main(String arg[]) { boolean b1=false,b2=false,b3=true; b1&=true;//line1 b2|=b1; //line2 b3^=b2|=b3;//line3 boolean b4=false | false;//line4 System.out.println(b1+"\n"+b2+"\n"+b3+"\n"+b4); } } output:false :true :false :false My Question:why line2 is true.If line2 is true than line4 also true.
H Gokulam
Ranch Hand
Joined: Nov 04, 2003
Posts: 46
posted
0
Hi, Line 2 doesn't produce a 'true'. It is line line 3 which is assigning 'true' to b2. Try commenting line 3... value b2 remains false. or just add System.out.println(b2); before line 3. Hope you got it !!
Harikumar G<br />SCJP 1.4
sanjana narayanan
Ranch Hand
Joined: Nov 25, 2003
Posts: 142
posted
0
can u tell me how this line b3^=b2|=b3;//line3 is getting executed with b2=true. -Sanjana
H Gokulam
Ranch Hand
Joined: Nov 04, 2003
Posts: 46
posted
0
Hi,
can u tell me how this line b3^=b2|=b3;//line3 is getting executed with b2=true.
Assignment operators are evaluated right to left. b3^=b2|=b3 will be like b3 = b3 ^ (b2 = b2 | b3) ie: b3 = b3 ^(b2 = false | true) here b2 will be assigned with value 'true'
jaysingh solanki
Greenhorn
Joined: Nov 11, 2003
Posts: 14
posted
0
Thanks hari now my concept is clear
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.