If two Strings are concatenated using “+” operator in a “for” loop, then it creates a new String Object, every time.
This causes wastage of Memory and increases Performance time.
Also, while instantiating a String Object, constructors should be avoided and instantiation should happen directly. For example:
//Slower Instantiation ❌
String bad = new String("string object");
//Faster Instantiation ✅
String good = "string object";
#memory #java #string
@ProgrammingTip