0

I have gone through this String Constant Pool Java but dint get any clarity I want to know how many objects are created i.e memory space allocated when

String s=new String("stackoverflow");
  1. Are 2 object created if stackoverflow is not available in string constant pool i.e one in string constant pool and the other in heap memory and s will be pointing to the one in heap memory..? or

  2. Only one object is created in heap memory...?

Sanket Makani
  • 2,491
  • 2
  • 15
  • 23
  • Out of curiosity, in what cases would this knowledge be useful? The only one I can think of is if you're writing a java compiler. – byxor Jun 23 '17 at 09:57
  • please answer in 1 or 2 I have gone through the other question but dint get any clarity – user7985169 Jun 23 '17 at 10:08

0 Answers0