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 Constant String Pool 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 "Constant String Pool " Watch "Constant String Pool " New topic

Constant String Pool

Pavan Shahi
Ranch Hand

Joined: May 01, 2006
Posts: 39
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.


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

Joined: Feb 02, 2006
Posts: 2023
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

[ 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.
I agree. Here's the link:
subject: Constant String Pool
It's not a secret anymore!