wood burning stoves 2.0*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Constant String Pool 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 "Constant String Pool " Watch "Constant String Pool " New topic
Author

Constant String Pool

Pavan Shahi
Ranch Hand

Joined: May 01, 2006
Posts: 39
Hi
When we create a string literal like

String str=�SCJP�;

Then what happen actually is a String Object is created on Constant String Pool or Object is created on heap as any other object and Constant String Pool contain only reference of that object crrated.

Thanks
Pavan


SCJP 1.4 (93%)<br />SCBCD 5 (96%)
wise owen
Ranch Hand

Joined: Feb 02, 2006
Posts: 2023
http://www.javaranch.com/journal/200409/Journal200409.jsp#a1
faisal usmani
Ranch Hand

Joined: Jan 14, 2006
Posts: 139
Hello Pavan ,

Welcome to Javaranch, regarding your question the literal is on heap and reference varibale to the literal is in String Pool .


Hope i answered you

-faisal
[ May 09, 2006: Message edited by: faisal usmani ]
Shaliey Gowtham
Ranch Hand

Joined: Mar 20, 2006
Posts: 104
Objects are always created on the heap.
The reference to the literal Objects are stored in the String pool.
And the reference variable str also contains the same value as the reference value in the String pool.
 
wood burning stoves
 
subject: Constant String Pool
 
Similar Threads
String Object and GC
String objects
String Objects
== and equals()
How many number of string objects are created?