String assignment differences

Can anybody know what is the difference between the following two String assignments:

String ref = "HAI"; and String obj = new String("HAI");

[154 byte] By [Ponmalara] at [2007-11-27 10:56:15]
# 1

The second is in 99% of all cases ****, because it creates a String "HAI" and then creates a new String with the same content, which is usually just a waste of memory.

also note that

ref.equals(obj) is true while ref == obj is false

CeciNEstPasUnProgrammeura at 2007-7-29 12:01:51 > top of Java-index,Java Essentials,Java Programming...
# 2

The first one might create a new String object, if that String hasn't already been used and interned, the second one definately always creates a new String object, regardless of any interning that's gone on

It's almost always inappropriate to use the second one

georgemca at 2007-7-29 12:01:51 > top of Java-index,Java Essentials,Java Programming...
# 3

Thanks a lot

Ponmalara at 2007-7-29 12:01:51 > top of Java-index,Java Essentials,Java Programming...