Which one is correct and why:
String dynamic = new String(); dynamic = \" where id=\'\" + unitId + \"\'\"; Or String dynamic = \" where id=\'\" + unitId + \"
As we know that String class is immutable so , String str="Hello String"; is the best way of using String class so we can avoid memory wastage.When string with the same value created.
String str="Hello String";