
public class StringTest3 {

	public static void main(String[] args) {
		String s, t, s1;
		
		s = new String("hello");
		t = new String("hello");
		if (s == t) System.out.println("1: Equal");
		else System.out.println("1: Different");
		
		s = "hello";
		t = "hello";
		if (s == t) System.out.println("2: Equal");
		else System.out.println("2: Different");
		
		s = new String("hello");
		t = "hello";
		if (s == t) System.out.println("3: Equal");
		else System.out.println("3: Different");		
		
		s = "hel"+"lo";
		t = "hello";
		if (s == t) System.out.println("4: Equal");
		else System.out.println("4: Different");
		
		s1 = "hel";
		s = s1 + "lo";
		t = "hello";
		if (s == t) System.out.println("5: Equal");
		else System.out.println("5: Different");

		System.out.println("\nUsing the \'equals\' method:\n");;
		
		s = new String("hello");
		t = new String("hello");
		if (s.equals(t)) System.out.println("1: Equal");
		else System.out.println("1: Different");
		
		s = "hello";
		t = "hello";
		if (s.equals(t)) System.out.println("2: Equal");
		else System.out.println("2: Different");

		s = new String("hello");
		t = "hello";
		if (s.equals(t)) System.out.println("3: Equal");
		else System.out.println("3: Different");	
		
		s = "hel"+"lo";
		t = "hello";
		if (s.equals(t)) System.out.println("4: Equal");
		else System.out.println("4: Different");
		
		s1 = "hel";
		s = s1 + "lo";
		t = "hello";
		if (s.equals(t)) System.out.println("5: Equal");
		else System.out.println("5: Different");

	}

}
