Java logoJava/
JAVA-P0063

Use `""` instead of `new String()` to create empty stringsJAVA-P0063

Major severityMajor
Performance categoryPerformance

Creating a new java.lang.String object using the default constructor wastes memory because the object so created will be functionally indistinguishable from the empty string constant "".

Java guarantees that identical string constants will be represented by the same String object. Therefore, you should just use the empty string constant directly.

Bad Practice

String a = new String("");
String a = "";

References