This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes ( Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "("String".toString() == "String")???" Watch "("String".toString() == "String")???" New topic
Author

("String".toString() == "String")???

wei liu
Ranch Hand

Joined: Dec 06, 2001
Posts: 56
Question 121)
Read this piece of code carefully
if("String".toString() == "String")
System.out.println("Equal");
else
System.out.println("Not Equal");
Answers

the code will compile an print "Equal".
the code will compile an print "Not Equal".
the code will cause a compiler error.
-----------------
the ans is the first one.why? Could anyone give me a clear idea?
esp.("String".toString() == "String")
wei liu
Ranch Hand

Joined: Dec 06, 2001
Posts: 56
This object (which is already a string!) is itself returned.
i know the explanation!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: ("String".toString() == "String")???
 
Similar Threads
I need help with Strings
String literals
'==' operator on String objects
String Class
Please Answer soon with explanation