Results 1 to 6 of 6

Thread: Don't know what is String Pool?

  1. #1
    Join Date
    Nov 2009
    Posts
    652

    Don't know what is String Pool?

    Hi friends,

    I an new to the java programming concept. It seems that the java concepts are very complex to understand. For me "String Pool" is one of difficult concept of java programming. I am not able to get what is String Pool?. I have referred many books for this concepts but didn't get proper details. If you knows anything about the String Pool, then please let me know that. I would greatly appreciate you help.

  2. #2
    Join Date
    Apr 2008
    Posts
    1,948

    Re: Don't know what is String Pool?

    String Pool is basically used to cut down the number of String objects from the JVM. Suppose if the string is already exists in the pool, then a reference to the pooled instance returns. Java programming language make this type of optimization and since strings are immutable & can be shared without fear of data corruption. Each time your code create a string literal, the JVM checks the string literal pool first. If the string does not exist in the pool, a new String object instantiates, then is placed in the pool.

  3. #3
    Join Date
    May 2008
    Posts
    2,012

    Re: Don't know what is String Pool?

    A JVM(Java Virtual Machine) comprises a string pool in which it keeps at most one object of any String. String literals always refer to an object in the string pool.Each string literal is a reference to an instance of class String.String objects created with the new operator do not refer to objects in the string pool but can be made to using String's intern() method. The java.lang.String.intern() returns an interned String, that is, one that has an entry in the global String pool. If the String is not already in the global String pool, then it will be added.

  4. #4
    Join Date
    Apr 2008
    Posts
    2,005

    Re: Don't know what is String Pool?

    String pool holds at most one object of any String. Literal of String often refer to an object in the string pool. Whenever any assignment is done for String first it check in the String Pool whether that String is already exist or not String objects created with the new operator do not refer to objects in the string pool. After using the string object returns to the pool in the pool there is no tool of gc. and object in the string pool is immutable.All the String Object in the java program which are created by assignment stored in the pool.

  5. #5
    Join Date
    May 2008
    Posts
    2,297

    Re: Don't know what is String Pool?

    Hi,

    The intention of using String pool in java is for to cut down the String objects created in the JVM. Please refer following example for the same:
    public class Pm1
    {
    public static void main(String args[])

    {

    String strB1 "Hi";
    String strA1 "Hi";

    System.out.print(strA1 strB1);

    }
    }

  6. #6
    Join Date
    May 2008
    Posts
    2,389

    Re: Don't know what is String Pool?

    A string pool is nothing but a collection of the references for to String objects. A java virtual machine has a string pool where it keeps at most one object of any String. String literals often refer to an object which is from the string pool. String objects created with the new operator do not refer to objects in the string pool. Objects are created on the heap and Strings are no exception. So, Strings that are part of the "String Literal Pool" still live on the heap, but they have references to them from the String Literal Pool. When a class is loaded, the JVM goes through the code for the class and looks for String literals.

Similar Threads

  1. How to Manipulate String using PHP String Functions
    By ComPaCt in forum Software Development
    Replies: 3
    Last Post: 21-09-2009, 09:07 AM
  2. Pool games for Wii
    By koen* in forum Video Games
    Replies: 3
    Last Post: 24-07-2009, 12:55 PM
  3. BSOD with Bad Pool Header
    By Sean J in forum Operating Systems
    Replies: 2
    Last Post: 05-11-2008, 03:20 PM
  4. American Pool Deluxe for Wii
    By kattman in forum Video Games
    Replies: 2
    Last Post: 11-09-2008, 01:32 PM
  5. Replies: 1
    Last Post: 13-10-2005, 04:48 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,553,952.98316 seconds with 17 queries