If we define two strings:

        String c=”123″;

String d=”123″;

        System.out.println(c==d);

The return value is true; Because the c and D strings that we’re defining are stored in memory, they’re actually referring to the same storage space. In debug mode, you can clearly see that the ids of the two strings are the same.

② If we instantiate two string objects, then we are comparing the two objects instantiated by the same class

As you can see, the ids of these two objects are different.

Finally: Two ways to determine equality: == and equal

Return true if both sides are exactly the same, false otherwise

Equal checks whether two objects are the same or not, so in the second example we use equal and return true if we use == we return false