There is a small difference between both.
Second declaration assignates the reference associated to the constant SOME
to the variable str
First declaration creates a new String having for value the value of the constant SOME
and assignates its reference to the variable str
.
In the first case, a second String has been created having the same value that SOME
which implies more inititialization time. As a consequence, you should avoid it. Furthermore, at compile time, all constants SOME
are transformed into the same instance, which uses far less memory.
As a consequence, always prefer second syntax.