wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes if (a==b==c) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "if (a==b==c)" Watch "if (a==b==c)" New topic
Author

if (a==b==c)

David Mroczkowski
Greenhorn

Joined: Nov 07, 2002
Posts: 12
I'm sure this basic is as do-re-mi, but here's another question that I need some help with...
boolean a = false;
boolean b = false;
boolean c = true;
if ( a==b==c){
System.out.println("true");
} else {
System.out.println("false");
}
This prints "true". Yes?
Then is the following prints the same?
boolean a = false;
boolean b = false;
boolean c = true;
if ((a==b)==c){
System.out.println("true");
} else {
System.out.println("false");
}
I'm preparing for the certification and sometimes the simple ones throw me.
Which way would be the preferred way?
Appreciate it,
d
Wirianto Djunaidi
Ranch Hand

Joined: Mar 20, 2001
Posts: 210

Both will be the same, because the rule of precedence the first program will be the same as the second one.
Of course it will be more user readable in the second one.
David Mroczkowski
Greenhorn

Joined: Nov 07, 2002
Posts: 12
Thank Ryo!
Sometimes you just need confirmation.
d
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: if (a==b==c)