Code for Program to show the use of Comparison operator (==) for comparing Strings in Java

publicclass JAVA_045
{
publicstaticvoid main(String[] args)
{
String String1="Too many ";
String String2="cooks";
String String3="Too many cooks";
String1+=String2;
System.out.println("Test # 1");
System.out.println("String3 is now : " + String3);
System.out.println("String1 is now : " + String1);
if(String1==String3)
System.out.println("String1==String3 is True, " +
"String1 and String3 point to the same String");
else
System.out.println("String1==String3 is False, " +
"String1 and String3 do not point to the same String");
String3=String1;
System.out.println("\n\nTest # 2");
System.out.println("String3 is now : " + String3);
System.out.println("String1 is now : " + String1);
if(String1==String3)
System.out.println("String1==String3 is True, " +
"String1 and String3 point to the same String");
else
System.out.println("String1==String3 is False, " +
"String1 and String3 do not point to the same String");
}
}