cool Tade

Greenhorn
+ Follow
since Aug 18, 2003
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by cool Tade

class A {
static boolean a;
static boolean b;
static boolean c;
public static void main (String[] args) {
boolean x = (a = true) || (b = true) && (c = true);
System.out.print(a + "," + b + "," + c);
}
}
The o/p is true,false,false
but i am unable to understand why
does'nt && have higher precedence than ||

Hi,
The evalutaion order is from left to right.
So after (a = true) becomes true the complier doen't evaluates the remaining part of code because of ||(Logical OR opetrator).As remaining experession doesn't get evaluted band c retain the value as false.
Regards
Ankur
(a = true)