The first form creates a new String
object each time you run it. The second form does not.
This applies to both Java SE and Java ME. Indeed, the basic representation of Java SE and Java ME strings is the same.
Using new String(...)
is almost always unnecessary and wasteful. There is rarely any point having a new instance. All String
objects are immutable in Java.
(There are rare situations where creating a new String is advisable. One is when you take a substring of a large String and that substring is likely to be reachable for much longer than the original one.)