Since strings are immutable in Java, why do I want to use the String constructor with no arguments and create an object?
How the variable sis useful to me after that:
s
String s = new String();
new String()- empty line. It can be a return value from a method, for example, if you have nothing to return. Using a literal ""is probably better because a literal empty string value will already be interned.
new String()
""
This is an empty string equivalent "". From javadoc:
String, . , , .
EDIT:
. , true:
true
"" == "" "" != new String() "".equals(new String())
Java, String ?
, , equal "", . , new String(str), str .
equal
new String(str)
str
, , . , , , ( , Java Java).