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 / birendra kumar

String constant pool is part of the heap memory. which is
manage the memory efficient by the JVM.

if you create String literal like..
//suppose pool is empty..

// str(is reference variable) and abc(is String object)

String str="abc";

/*Creating on String object and one reference variable.
so abc is stored in pood and str is refered it. */

//if you created another String literal with same content like..
String str1="abc";

/* it is only creating reference variable which is point
same String object "abc". because of JVM is checking first
if any content with same string object in the pool just it
is make the reference not created new String object*/

if you creating String Object using new keyword like..

String str2=new String("abc");

/* creating two object and one reference variable*/
because here we used new keyword and it is creating normal
object in the heap(non pool)memory.where 1st object is
stored and str is refered to it. and 2nd object is stored as
it is in string pool.

that is reasion in java if you match with str with str2
using (==) operator it will give you false result because of
(==) operator is match basis of reference variable which is
pointing same object if you use equals method then you get
true.basis of content of the reference variable in .

Is This Answer Correct ?    15 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

when you will synchronize a piece of your code? : Java thread

961


What is string value?

1087


What is final?

1003


What is pangram in java?

959


What is garbage collector?

1007


What is operator overloading. Is it is supported in java?

945


Can we sort arraylist in java?

937


What is Mutex (Mutual Exclusion Object) ?

1078


Can we override the static method?

962


What is the reflection?

943


What is t in generics in java?

998


What are green threads in java?

945


What is the maximum size of array in java?

925


How many types of array are there?

951


How to create a custom exception?

947