The equals method is defined in the Object class, the mother of all classes which every class implicitly extends.
The implementation in the object class is quite simple and often not what you want.
It returns true if you call the method from an object and pass in the identical object as an argument. The same what == comparison would result.
This is why the equals method often needs to be overridden to compare the classes field values instead of just the object reference.
String overrides equals() to deeply compare two Strings, meaning the content of the underlying char array.
Note that you must override hashCode if you override equals.
More on the topic:
This might help to visualise the diffrenece.
String x = "hello";
String y = new String("hello");
//i have to create a new string object of hello here beacuse if i didnt x and y would both be pointing to the same "hello" in string pool meaning that there refrences would be the same if compared.
System.out.println("Are both values the same? "+x.equals(y));
System.out.print("Are both refs the same? "+(x==y));