I have previously asked a question about comparing 2 strings and was told that I should always use .equals.
However, I do not understand why this then works:
String y= "Mary";
String x= "Mary";
System.out.print(x==y);
This will print true, and I do not understand why.