Edit: Apparently == doesn't work properly with strings.
== works with strings, but maybe not exactly in the way you may think
In Java, for each variable that you declared, after allocating it (with the new operator) a reference to the memory location for that allocation is stored inside the variable. Then, whenever you use that variable in your code the program will know where in memory to get the data that you are trying to retrieve.
Example: Very simplified, but see it like this. Imagine you are reading two strings from input as follows:
Scanner scan = new Scanner(System.in);
String s1 = scan.nextLine(); //user types Hello
String s2 = scan.nextLine(); //user again types Hello
s1 references a location in memory where the physical bytes containing "Hello" is stored. s2 will similarly reference a different memory location containing "Hello".
Now here comes the interesting part. The == operator compares references to each other, and not the contents of these references. Basically s1 == s2 will check whether both s1 and s2 references the same memory location. In this case, the answer will be false.
String however has an "equals" function that will compare the contents of its memory with another String's contents. In this case s1.equals(s2) will return true, as "Hello" was contained in both of them.
Hope this makes sense. But watch out for the following:
Imagine you didn't read the strings from input but instead declared them as follows:
String s1 = "Hello";
String s2 = "Hello";
The result of s1.equals(s2) is obviously true, but surprisingly s1 == s2 also returns true? The reason is that Java was quite smart to see that the contents of s1 and s2 are both the same, and decided to hold this contents in the same memory location for both. Basically, both s1 and s2 will reference the same memory. This is possible because the strings were string constants and their values could be predetermined during compilation (in contrast to the previous example where the values were only available at runtime). So when you deal with string constants, keep the above in mind.