public class abc {
public static void main(
String args[]) {
String str1 = "string1";
String str2 = "string1";
System.out.println(str1==s.str);
System.out.println(str1.equals(str2));
System.out.println(str1=="string1");
}
}
I tried the above comparisons and got the result as 'true' in all the three cases. but if i initialize str1 and str2 as :
String str1 = new String("string1");
String str2 = new String("string1");
This comparison returns false.
plez explain the reason for the same...i will be greatful....
Monika