Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

what is meant by string pooling?

Answer Posted / vijay srivastava

Most of the Answers are correct but they are not much clear so I am trying write clear Answer. I hope, you guys will like it.

String pooling is the mechanism that was introduced by Java.
String pooling is possible because String is immutable and final class.

1- String firstString = "Hello";
2- String secondString = "Hello";
3- String thirdString = new String("Hello");
There is no guarantee to create new object for string Step 1 and 2 but in step 3, Jave(JVM) gives guarantee to create object.
In step 1st and 2nd, JVM search the same literal in String pool if it's available then return the reference else JVM will create the object for same and added in to String pool.
In step 3, JVM definitely create the new object, It will not part of String pool. If we want this newly created object should be part of String pool then we need to call intern() method of String class. If we called intern() method then JVM will search the same literal in String pool if JVM found same literal then return reference else JVM will add the same object in String pool.

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How does the garbage collector works in java?

1041


Can we call the run() method instead of start()?

983


What do you mean by ordered and sorted in collections in java?

942


What is difference between path and classpath variables?

1031


What are multiple inheritances? Is it supported by java?

887


What are different access specifiers in java? Explain

1055


What are the advantages and disadvantages of reference counting in garbage collection?

971


Write a function to print Fibonacci series and Tribonacci series?

1126


How many static init can you have?

1143


Java is pass by value or pass by reference? Explain

933


What is sizeof () operator?

925


What is the purpose of a volatile variable?

975


What will happen if there is a default method conflict as mentioned above and we have specified the same signature method in the base class instead of overriding in the existing class ?

897


what is static import in java? Explain

960


What does java stand for?

1039