if I write a below code
Scenario-1 [Initially no value in string constant pool]
String s1 = new String("test");
then how many object created?
As per my answer : two object created :: one is in string literal pool and other is in heap because of new reference : refer link
why char[] show in refer link
Scenario-2 [Initially no value in string constant pool]
String s1 = "test";
String s2 = new String("test");
then how many object created?
As per my answer : three object created :: one is in string literal pool for s1 and second is in heap because of new for s2 and third is char[] for s2 reference : refer link
my answer is correct?? please give me exact idea for this which one is right??