wood burning stoves 2.0*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Why doesnt this compile? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Why doesnt this compile?" Watch "Why doesnt this compile?" New topic
Author

Why doesnt this compile?

rohan yadav
Ranch Hand

Joined: Oct 13, 2009
Posts: 156


Why the compiler is giving compiler error??
This question from ExamLab


Sage of The Monstrous Toad of Mount Myoboku
Raju Champaklal
Ranch Hand

Joined: Dec 10, 2009
Posts: 521
s1==s2+","+s2 will give false....and then you are comparing a boolean with a string which is illegal


scjp 1.6 91%, preparing for scmad
"Time to get MAD now.. we will get even later"....by someone unknown
Rafael Angarita
Ranch Hand

Joined: Jan 09, 2009
Posts: 67
Yes!...Try enclosing the string comparisons between parenthesis and see what happens!


Rafael Angarita.
SCJP 6.
Raju Champaklal
Ranch Hand

Joined: Dec 10, 2009
Posts: 521
this is because + comes higher in the table than == so first the strings are added and then compared....you get a boolean...and then boolean is compared with a string which is illegal?

understood man?

nice question by the way....this helped clear my concept of the table
rohan yadav
Ranch Hand

Joined: Oct 13, 2009
Posts: 156
Understood now:
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Why doesnt this compile?
 
Similar Threads
General problems..
How many String object created?
What the output related to string
== with Strings is giving a different result
String and String Object Problem