differences between string literal and string object code example
Example: string literal vs string object
String literal (String str = "abc";)
String Object (String str = new String("abc");)
In String object JVM is forced to
create a new string reference,
even if “abc” is in the reference pool.
String object always takes long time to
execute than String literal because it will
construct new string everytime we run the
program.