This week's book giveaway is in the Performance forum.
We're giving away four copies of The Java Performance Companion and have Charlie Hunt, Monica Beckwith, Poonam Parhar, & Bengt Rutisson on-line!
See this thread for details.
Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

String Output related.

 
Pinki Roy
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator



I do not understand why this is giving the output of False. Please explain.
 
Joe Harry
Ranch Hand
Posts: 10124
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is a good chance for you to explore a little bit and understand the ideas behind reference equality, object equality and perhaps String immutability.
 
Rahul Shinde
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The String class is immutable, once it is created a String object cannot be changed.

You might want to do .equals() instead to check for contents. i.e.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic