+ 28

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?

6th Jul 2018, 4:40 AM
World Champion
World Champion - avatar
16 odpowiedzi
+ 7
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.
7th Jul 2018, 6:07 AM
Jain Rishav Amit
Jain Rishav Amit - avatar
+ 17
Thanks Tarika for your answer
6th Jul 2018, 2:06 PM
World Champion
World Champion - avatar
+ 14
Thanks a lot Jain Rishav Amit for your elaborate explanation👍
7th Jul 2018, 6:12 AM
World Champion
World Champion - avatar
+ 14
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
7th Jul 2018, 10:09 AM
Jakub Dubański
Jakub Dubański - avatar
+ 14
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
7th Jul 2018, 10:31 AM
Jakub Dubański
Jakub Dubański - avatar
+ 5
Thanks for the info Jakub Dubański Sounds interesting.. I will be looking forward to use it..
7th Jul 2018, 10:34 AM
Jain Rishav Amit
Jain Rishav Amit - avatar
+ 5
also you can use method hashCode( ) to see how two String refer to each other if there content are same . i.e
7th Jul 2018, 10:44 AM
Tarika
Tarika - avatar
+ 4
thankq Jain rishav amit
8th Jul 2018, 8:03 AM
payal Triveri
+ 3
Jakub Dubański I am not aware about Mission control... whats that?
7th Jul 2018, 10:17 AM
Jain Rishav Amit
Jain Rishav Amit - avatar
+ 1
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.
6th Jul 2018, 12:30 PM
Tarika
Tarika - avatar
0
im want lern writ📝 Ap java but littel langoech english and no univer sit student im hom mayker and iron im help
7th Jul 2018, 5:33 AM
fatima purramezan
fatima purramezan - avatar
0
👌👌👉
3rd Sep 2018, 8:57 AM
Mack Charan
Mack Charan - avatar
0
thanks for ur answer
18th Jan 2019, 7:55 PM
Akash Singh
Akash Singh - avatar
0
Ok
21st Sep 2019, 11:53 PM
Lubens Luma
Lubens Luma - avatar
- 1
Hi
15th Apr 2020, 3:23 AM
Zapata
- 4
Hello Where are you from???
9th Jul 2018, 6:58 AM
Poorya Rahdar
Poorya Rahdar - avatar