String string1 = \"Hi there\";
String string2 = \"Hi\";
String string3 = \"Hi\";
System.out.println(string1.substring(0, string2.length()) == string2); //1
System.o
The == operator is comparing 2 references to the same string for equality.
The String class has two methods that you should use to compare two strings for equality:
String1.equals(String2);
Returns true if String1 and String2 are identical (including the case of the letters).
If you don't care about the case then you can use:
String1.equalsIgnoreCase(String2);
This returns true if String1 and String2 are equal regardless of the case (obviously).