This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan 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 Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Another String object confusion" Watch "Another String object confusion" New topic
Author

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.

Thanks
[ 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.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Another String object confusion
 
Similar Threads
need help for a question
How many String objects have been created?
Is Kathy&Bert book wrong? Or my understanding wrong?
String is created on pool?
Yet another string pool doubt