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

why string constant pool in java

Answer Posted / loknathreddy

String constant pool is a separate block of memory where
String object are held by JVM.
If a String object is created directly by using assignment
operator(=) as
String s1="Hello";
then it is stored in String Constant pool.
One of important characteristic of String constant pool is
that it doesn’t create same String object if there is
already in the String constant pool.

String s1 = “Hello”;
String s2 = “Hello”;

For above two String objects, JVM creates only one object
in the String constant pool and for the second string
reference variable (s2) will created, it points the string
object which is created for s1. In this case, (s1 == s2) is
true.
but when we use new operator to create object then this
object will store in heap memory.. be carefull on this.

Is This Answer Correct ?    26 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Name some OOPS Concepts in Java?

1019


How do you define a method?

924


What lambda means?

937


Which graphs are functions?

900


What do you mean by local variable and instance variable?

896


How can I debug the Java security exceptions and AccessControlExceptions?

1091


which class is the wait() method defined in? : Java thread

888


What is a vector in java?

972


Write a program in java to find the maximum and minimum value node from a circular linked list.

1006


What is difference between classpath and path variables in java?

1133


How do you use compareto in java?

923


What is break and continue statement?

1027


What is class and object in java?

946


What is meant by object oriented programming – oop?

922


what is static import in java? Explain

961