As you know Java == compares the references, it asks whether two objects are actually the same object, not just having the same value.
String x = "abcgrfdhdrhfhtjfhtgdrfdjrtkkytjgykjgrthfd";
String y = "abcgrfdhdrhfhtjfhtgdrfdjrtkkytjgykjgrthfd";
System.out.println(x == y);
In this case you have assigned x and y to point to the exact same String. Internally the Java compiler has noticed that both x and y are being given the same value, so to save space it has created only one String object - and then both x and y point to that object.
This is why x == y..
If you changed one or the other (or both) to:
String x = new String("abcgrfdhdrhfhtjfhtgdrfdjrtkkytjgykjgrthfd");
Then you would get the result false
.