1.

What Are The Different Ways Of Creating A String Object In Java?

Answer»

String objects in java can be created either by using the NEW keyword or by using a string LITERAL.

String Creation using a Literal

String STR= “DeZyre”;

String Object Creation using the “new” OPERATOR -

String str=new String ("DeZyre"); //creates two objects and one reference VARIABLE

String objects in java can be created either by using the new keyword or by using a string literal.

String Creation using a Literal

String str= “DeZyre”;

String Object Creation using the “new” operator -

String str=new String ("DeZyre"); //creates two objects and one reference variable



Discussion

No Comment Found