+ 1
What is String Constant Pool in java?
5 Respuestas
+ 2
Thanks a lot! Got a clear idea🤘✨
+ 1
But what is its use?
+ 1
Gauri Shirkande Go through the link given by @Nilesh. It has all explanations..
Bwt in short for you, Java uses a separate memory location for storing string literals. That area of memory location is called String Constant pool.. So use is storing string constants, which you used in your programs..
Java maintains this for better security through string immutability.. means not modifiable. See in pool, same values of different variables, pointing to single location., not a different locations.. Hope it helps...
0
Two equal string literals and one memory place - it saves memory.
All string in one memory area - it saves speed because with the new string it has to check if it is in the pool.