About 105,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. 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 …

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

    Feb 7, 2011 · The answer is technically neither. According to the Java Virtual Machine Specification, the area for storing string literals is in the runtime constant pool. The runtime constant pool memory area …

  5. 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 …

  6. 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 …

  7. 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?

  8. When will a string be garbage collected in java - Stack Overflow

    Jul 18, 2020 · In Java, when an object has got no live reference, it is eligible for garbage collection. Now in case of a string, this is not the case because the string will go into the string pool and JVM will ...

  9. What is Java String interning? - Stack Overflow

    May 14, 2012 · String pooling is Java's way of saving program memory by avoiding the creation of multiple String objects containing the same value. It is possible to get a string from the string pool for …

  10. What is the purpose of the Java Constant Pool? - Stack Overflow

    Apr 18, 2012 · For each type it loads, a Java virtual machine must store a constant pool. A constant pool is an ordered set of constants used by the type, including literals (string, integer, and floating point …