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: 1 //Slower Instantiation 2 String bad = new String( "Yet another string object" ); 3 4 //Faster Instantiation 5 6 String good = "Yet another string object";
Technology - Marketing - Stocks - Views