Java

Java

Made by DeepSource

Inefficient use of String constructor JAVA-S0062

Performance
Major

Creating a String using object creation wastes memory because the new String object so constructed will be functionally indistinguishable from the String value passed as a parameter. Just use the string directly.

Examples

Problematic Code

String a = new String("abc");

Recommended

String a = "abc";

References