This week's book giveaway is in the JDBC forum.
We're giving away four copies of Make it so: Java DB Connections & Transactions and have Marcho Behler on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Another String object confusion Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Make it so: Java DB Connections & Transactions this week in the JDBC forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Another String object confusion" Watch "Another String object confusion" New topic

Another String object confusion

Francis Palattao
Ranch Hand

Joined: Sep 22, 2004
Posts: 91
String a = "test";
a = null;
String b = "test";

Line 1 creates a new string instance and then places it in the String pool. Is that correct?

Also does Line 3 recreate a new object or does it use the object that was placed in the String pool. I'm confused about the relation between the String pool and the heap.

[ November 04, 2004: Message edited by: Francis Palattao ]

SCJP 1.4 <br />SCWCD 1.4 (preparing)<br />SCBCD 1.3 (coming soon)
Corey McGlone
Ranch Hand

Joined: Dec 20, 2001
Posts: 3271
Try reading this.

SCJP Tipline, etc.
I agree. Here's the link:
subject: Another String object confusion
It's not a secret anymore!