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
Is java an open source?
What are pass by reference and pass by value?
What are some examples of variable costs?
What is meant by bytecode?
Explain the init method?
Explain yield() method in thread class ?
Which is better stringbuffer or stringbuilder?
What do you mean by mnemonics?
What is Gang of four design patterns
What is == and === in javascript?
Differences between traditional programming language and object oriented programming language?
What's the purpose of static methods and static variables?
What is another word for methodology?
What is jvm? Why is java called the platform independent programming language?
What is the difference between jdk and jre?