File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
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.
subject: Another String object confusion
It's not a secret anymore!