• Dear Guest, Please do NOT forget to join our JAVA JOBS (ONLY) FACEBOOK GROUP to be aware of latest JAVA openings, and you may also post any JAVA related queries/jobs.

string objects

Hi all
i'm new to java ,my Question is
case 1:
String a="hello";
String b="world";

Case 2:
String a="hello";
a=new String("world");

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))

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.