This week's book giveaway is in the Other Languages forum.
We're giving away four copies of Functional Reactive Programming and have Stephen Blackheath and Anthony Jones on-line!
See this thread for details.
Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
wei liu
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This object (which is already a string!) is itself returned.
i know the explanation!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic