what is meant by string pooling?
Answer Posted / indrajit yadav
A string pool is a collection of references to String
objects."String Literal Pool" still live on the heap memory,
but they have references to them from the String Literal Pool.
See the below example:
public class Program {
public static void main(String args[]){
//String literal will store in String pool
String s1="Indrajit";//case 1
String s2="Indrajit";//case 2
//In case 1, iteral s1 is created newly and kept in the
pool. But in case 2, literal s2 refer the s1, it will not
create new one instead
//String object
String s = new String("hi");
String ss = new String ("hi");
if (s1==s2){
System.out.print("equal");//print equal
}
/*
if(s==ss){
System.out.print("Reference are not equal");//no ouptput
}
*/
}
}
| Is This Answer Correct ? | 24 Yes | 1 No |
Post New Answer View All Answers
What are some characteristics of interference class?
What are format specifiers in java?
What are the types of methodology?
Which access specifier can be used with class ?
what is the role of xml in core java?? and how we can use it?? can somebody give a sample program with explanation and from where i can read more about xml?????
Are variables stored in ram?
What is multiple inheritance? Is it supported by java?
Define max and min heap, also the search time of heap.
What are the 5 types of research methods?
What does || mean in code?
what is interface in java? Explain
What is a variable in java?
Does isempty check for null?
What is t in generics in java?
Is there any way to find whether software installed in the
system is registered by just providing the .exe file?
I have tried the following code but its just displaying the
directory structure in the registry.
Here the code :
package com.msi.intaller;
import java.util.Iterator;
import ca.beq.util.win32.registry.RegistryKey;
import ca.beq.util.win32.registry.RootKey;
public class RegistryFinder {
public static void main(String... args) throws Exception
{
RegistryKey.initialize(RegistryFinder.class.getResource("jRe
gistryKey.dll").getFile());
RegistryKey key = new RegistryKey(RootKey.HKLM,
"Software\\ODBC");
for (Iterator