• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Constant String Pool

 
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 2023
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
http://www.javaranch.com/journal/200409/Journal200409.jsp#a1
 
Ranch Hand
Posts: 139
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
reply
    Bookmark Topic Watch Topic
  • New Topic