Bookmark Topic Watch Topic
  • New Topic

Output of this snippet.

 
Chandrakanth
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Report post to moderator
can you pls, tell me how is the output of this prog is true false false.

my understanding is this:
() have higher precedance than || and && so all of the () operators should be evaluated?
so abc will get the value of true.
than only short circuit operators should be applied...

class EBH202 {
static boolean a, b, c;
public static void main (String[] args) {
boolean x = (a = true) || (b = true) && (c = true);
System.out.print(a + "," + b + "," + c);
}
}
 
Barry Gaunt
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
  • Report post to moderator
Duplicate. Closing.
 
    Bookmark Topic Watch Topic
  • New Topic