InterviewSolution
Saved Bookmarks
| 1. |
What is the String pool in java? |
|
Answer» Strings are immutable in Java. When we make changes in a String, it creates a new String OBJECT. Our PROGRAMS create a LOT of String objects in the runtime. To offer optimum performance, JVM minimizes the String object creation maintaining a pool of String literals in the heap memory (Java 7 onwards). So, when it is required to create a String literal, it first checks in the pool, whether it exists there. If found, it returns the reference of that object. Otherwise, it creates the object and reserves it in the pool for REUSING it in a later phase. |
|