what is meant by string pooling?
Answer Posted / ranganathkini
A string pool is a collection of references to String
objects. Strings, even though they are immutable, are still
objects like any other in Java. 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 .java file is compiled into a .class file, any String
literals are noted in a special way, just as all constants
are. When a class is loaded (note that loading happens prior
to initialization), the JVM goes through the code for the
class and looks for String literals. When it finds one, it
checks to see if an equivalent String is already referenced
from the heap. If not, it creates a String instance on the
heap and stores a reference to that object in the constant
table. Once a reference is made to that String object, any
references to that String literal throughout your program
are simply replaced with the reference to the object
referenced from the String Literal Pool.
| Is This Answer Correct ? | 37 Yes | 4 No |
Post New Answer View All Answers
What are the differences between forwarding () method and sendredirect() methods?
What is structure of java heap? What is perm gen space in heap?
Differentiate between postfix and prefix operators in java.
What is final class?
What is the meaning of variables in research?
How many types of gc are there in java?
How to find the largest value from the given array.
What is hash table in java?
Q1.A. Write note on “The class path Environment Variable”? B. Which are different kinds of source code? Q2.A. How to create an interface? B. Why convert an applet to an application? Q3.A. How to use Media tracker Class. B. How to use string tokenizer class. Q4 A. Explain the overview of UDP messaging. B. Difference between SQL Exception class and SQL Warning class. Q5. A. How to create com object in Java? B. Write short notes on “The properties class” Q6. A. When object is created and destroyed? B. Explain the JDB in depth & command line. C. Write short notes on Web Sites.
How can the checkbox class be used to create a radio button?
What defines function?
What are annotations in java?
What is a map? What are the implementations of map?
Can a method be overloaded based on different return type but same argument type?
Is void a type?