About 171,000 results
Open links in new tab
  1. What is String pool in Java? - Stack Overflow

    It's safe because String is immutable in Java. As result, both s and t point to the same object and some little memory saved. Name 'string pool' comes from the idea that all already defined string are stored …

  2. What is the Java string pool and how is "s" different from new String ...

    The string pool allows string constants to be reused, which is possible because strings in Java are immutable. If you repeat the same string constant all over the place in your Java code, you can …

  3. Questions about Java's String pool - Stack Overflow

    String first = "abc"; String second = new String("abc"); When using the new keyword, Java will create the abc String again right? Will this be stored on the regular heap or the String pool? How many String s …

  4. java - String pool vs Constant pool - Stack Overflow

    The "string pool" is a thread-safe weak-map from java.lang.String instances to java.lang.String instances used to intern strings. Chapter 3.10.5. String Literals says A string literal is a reference to an instance …

  5. Where does Java's String constant pool live, the heap or the stack?

    Feb 7, 2011 · The runtime constant pool is a subset of the method area which "stores per-class structures such as the runtime constant pool, field and method data, and the code for methods and …

  6. String pool in java 8 - Stack Overflow

    Feb 15, 2017 · Nothing special is happening in Java 8. Compile-time strings are still placed in a pool and you can still intern your own in the program if you like. Why do you think this should have changed?

  7. How does Java implement String pooling? - Stack Overflow

    Feb 19, 2016 · Closed 9 years ago. I want to understand the string pool more deeply. Please help me get to the source class file containing this implementation in Java. The question is more of related to …

  8. Increased memory consumption due to String Constant Pool behavior …

    Apr 3, 2025 · While upgrading our project from Java 17 to Java 21, we noticed an increase in memory consumption. After dumping the heap and analyzing the differences, I found that there are thousands …

  9. java - String Constant Pool - Stack Overflow

    Jan 4, 2013 · In such a case, references to String literals are still put into the constant table (the String Literal Pool), but, when you come to the keyword "new," the JVM is obliged to create a new String …

  10. String POOL in java - Stack Overflow

    Jan 9, 2012 · Java has string pool, due to which objects of string class are immutable. But my question stands - What was the need to make String POOL? Why string class was not kept like other class to …