Strings Creation?

Wat is the difference between String str1 = "india"; String str2 = new String("india");Plz tell me, i'm new to Strings.
[149 byte] By [Mylovegr8a] at [2007-10-3 4:01:50]
# 1
>Plz tell me, i'm new to Strings.Are you new to Google as well?Simple answer: Don't use 'new String("foo")'!
JoachimSauera at 2007-7-14 22:01:08 > top of Java-index,Java Essentials,Java Programming...
# 2

> Simple answer: Don't use 'new String("foo")'!

Although 'new String("foo")' is something that it doesn't make sense to do, there are legitimate reasons why you might want to use new String(s) where s is a String. If s was recovered by using the substring() method (or using the regex library) from a much larger String (like a large XML file) then s may be backed by the large char[] array from the original String (so taking up a large amount of memory).

In this instance, new String(s) will not reference the entire character array from the original String. This is a non-obvious source of most Java memory leaks I've come across.

oxbow_lakesa at 2007-7-14 22:01:08 > top of Java-index,Java Essentials,Java Programming...
# 3

Strings instantiated without the new operator and intrinsically interned while the ones with new operator are not, Try

String a = "test";

String b = "test";

System.out.println(a==b);

and then try

String a = new String("test");

String b = new String("test");

System.out.println(a==b);

Anyway using new for String doesnot make sense anyway.

kilyasa at 2007-7-14 22:01:08 > top of Java-index,Java Essentials,Java Programming...
# 4
> Anyway using new for String doesnot make sense anyway.Except for the case I've just outlined.
oxbow_lakesa at 2007-7-14 22:01:08 > top of Java-index,Java Essentials,Java Programming...