public class StringEqualityTest {
public static void main(String arg[]){
String str1 = "abc";
String str2 = "abc";
String str3= new String("abc");
String str4 = arg[0]; //input "abc" in command-line
String str5 = arg[1]; //input "abc" in command-line
if(str1 == str2) // returns true
System.out.println("Equals 1=2");
if(str1 == str3) // returns false
System.out.println("Equals 1=3");
if(str4 == str5) // returns false
System.out.println("Equals 4=5");
}
}
public static void main(String arg[]){
String str1 = "abc";
String str2 = "abc";
String str3= new String("abc");
String str4 = arg[0]; //input "abc" in command-line
String str5 = arg[1]; //input "abc" in command-line
if(str1 == str2) // returns true
System.out.println("Equals 1=2");
if(str1 == str3) // returns false
System.out.println("Equals 1=3");
if(str4 == str5) // returns false
System.out.println("Equals 4=5");
}
}