Then s and t actually refer to the same String object, and ‘s = t’ will return true, because for objects the double equal sign ('=') reads as 'is the same object'. Nor can you extend String, because it's declared as final, meaning no sub-classing is allowed (if you're not into inheritance that's ok for now). Strings are special in Java - they're immutable, and string constants (=variables that do not change) are automatically turned into String objects. You can override the standard equals() method from to implement a custom equals() method.
In general both the equals() method and “=” operator in Java are used to compare objects to check equality but the ‘’=’ operator’ checks if both objects point to the same memory location whereas the equals() method evaluates the values inside the objects. Getting to know the String class in java took me some time. Come back to this answer later and review again. If you dont fully understand this topic right now, it's fine. This goes beyond your question but is important to realise when working with Strings in Java (and Strings are everywhere). To elaborate a little further on String equality.