Hi,

I was reading about the Java8 Metaspace the other day, then got into the topic 
of string pool. I got conflicting information regarding a couple of things, I 
wonder if I can get a definitive answer from the experts?

#1: Is the string literal/constant pool a heap area that holds actual string 
literal objects or a place that holds references to string literal objects?
Reference: 
http://stackoverflow.com/questions/11700320/is-string-literal-pool-a-collection-of-references-to-the-string-object-or-a-col

#2: Is the following statement correct?

String str = new String("Cat");
In above statement, either 1 or 2 string will be created. If there is already a 
string literal "Cat" in the pool, then only one string "str" will be created in 
the pool. If there is no string literal "Cat" in the pool, then it will be 
first created in the pool and then in the heap space, so total 2 string objects 
will be created.

>From http://www.journaldev.com/797/what-is-java-string-pool#comment-36152


Apprciate your answers,
Jun

Jun Zhuang
Sr. Performance QA Engineer | 
Hobsons<https://www.hobsons.com/?utm_source=outlook&utm_medium=email&utm_campaign=banner_02.12.16_general>
T: +1 513 746 2288 | jun.zhu...@hobsons.com
50 E-Business Way, Suite 300 | Cincinnati, OH 45241 | USA


Upgraded by Hobsons - Subscribe Today
_______________________________________________
hotspot-gc-use mailing list
hotspot-gc-use@openjdk.java.net
http://mail.openjdk.java.net/mailman/listinfo/hotspot-gc-use

Reply via email to