String pool memory | Sololearn: Learn to code for FREE!


String pool memory

I am only aware of two kinds of memory stack and heap.Is string pool memory some different kind of memory?If not then why is it given a separate name?

7/6/2018 4:40:38 AM

World Champion

16 Answers

New Answer


String pool is a memory area within the heap memory area only i.e. it is not any other kind of memory area... String object when created using double quotes, jvm first check for the string in pool and if the string already exits, then same reference is given to the object and if no string is found in pool then new string is added to the pool and reference of this is given. In other case, when we create a string object with new operator, then in this case JVM creates a new string object in the Heap itself instead of searching for the string in the pool.


Thanks Tarika for your answer


Thanks a lot Jain Rishav Amit for your elaborate explanation👍


Yeeaah, String subject. To really understand it, use some IDE and a debugger, put a breakpoint and compare different scenarios. It is worth more than any lesson read. EDIT: please use Mission Control too


It is a java performance tool, highly recommend it for You to test and play with it. A lot of tutorials are telling how things work, but I believe it is better to "see" memory address and think for a while why and how it is done internally


Thanks for the info Jakub Dubański Sounds interesting.. I will be looking forward to use it..


also you can use method hashCode( ) to see how two String refer to each other if there content are same . i.e


thankq Jain rishav amit


Jakub Dubański I am not aware about Mission control... whats that?


as far as i know objects are store in a heap and variables are in stack, 1/3 rd of heap memory is reserved for string literal pool.


im want lern writ📝 Ap java but littel langoech english and no univer sit student im hom mayker and iron im help




thanks for ur answer




Hello Where are you from???