aspose file tools*
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
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")???