string objects

#1
Hi all
i'm new to java ,my Question is
case 1:
String a="hello";
String b="world";
a=a+b;
System.out.println(a);

Case 2:
String a="hello";
a=new String("world");
System.out.println(a);

i would like to know how many objects be created in each case. because String is immutable so once value is assigned to it that object cannot be reused(to my under standing(else correct me please))

Thanks
 
#4
String Literals. A string strict will be zero or that's only the tip of the iceberg characters encased over single alternately twofold citation marks. A string strict need an essential (primitive) information sort of string. An string object will be made Toward utilizing those new Operator, and need a information kind of object.
 
Top