We can create String using literal or with the new operator. As far as I understand, the literal will be stored in the String pool and when we use the new operator, a new object is created explicitly. I want to know if the String pool resides in the stack or heap memory. Also as per my understanding, the string object created using the new operator is stored in the heap. Please let me know if my understanding is correct.
Asked
Active
Viewed 31 times
0
-
Possible duplicates http://stackoverflow.com/questions/3052442/what-is-the-difference-between-text-and-new-stringtext – Cyclops Oct 22 '15 at 05:01
-
The string intern pool used to get stored in the permgen in the heap before java 8. Now it just gets put in the heap - http://stackoverflow.com/a/10579062/792238 – Siddhartha Oct 22 '15 at 05:03