• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

if (a==b==c)

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 218
VI Editor Ruby Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank Ryo!
Sometimes you just need confirmation.
d
 
What do you have to say for yourself? Hmmm? Anything? And you call yourself a tiny ad.
Clean our rivers and oceans from home
https://www.kickstarter.com/projects/paulwheaton/willow-feeders
reply
    Bookmark Topic Watch Topic
  • New Topic