File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

is getting me confused

 
vinayak manda
Ranch Hand
Posts: 31
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
vinayak manda
Ranch Hand
Posts: 31
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'am sorry, I couldn't post the question before...

The question is when String s3 gets the value "EFG" and later s4 also gets the value "EFG", as the literal goes into the string pool,then s3 and s4 should point to the same reference.
Then why should (s3 == s4) return false.

Please clear this doubt.
 
Barry Gaunt
Ranch Hand
Posts: 7729
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
s3 gets a reference to a new String("EFG") and s4 gets a reference to another new String("EFG"). So s3 and s4 refer to different objects. Therefore s3 == s4 results in false.
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Only String literals go into the pool by default. You can use the intern() method for the others to enforce them to get into the pool, too.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic