Skip to main content
added 4 characters in body
Source Link
Jigar Joshi
  • 241.4k
  • 42
  • 409
  • 446

if i create a string object as

String s=new String("Stackoverflow");

String s=new String("Stackoverflow"); 

will String object created only in heap, or it also makes a copy in String constant pool.

Thanks in advance.

if i create a string object as

String s=new String("Stackoverflow");

will String object created only in heap, or it also makes a copy in String constant pool.

Thanks in advance.

if i create a string object as

String s=new String("Stackoverflow"); 

will String object created only in heap, or it also makes a copy in String constant pool.

Thanks in advance.

Source Link

what happens with new String("") in String Constant pool

if i create a string object as

String s=new String("Stackoverflow");

will String object created only in heap, or it also makes a copy in String constant pool.

Thanks in advance.