In Java, one should exactly distingish Objects and their references. Take the following as an example:
Animal a = new Bird();
This means 3 steps: 1) Declare a variable with a type of Animal; 2) Create a Bird (Animal) according to the shape of a bird, using key word "new"; 3) Assign this Bird(Animal) to variable a. "a" is a kind of reference.
In Java, to judge where two Object references point to the same Objects or not,
we use the operator ==. This is called "shallow comparison".
Now on your issue. You created 2 Strings. However, your assignment is wrong. You did not follow the following rule: Assign an Object to an Object reference.
You created two Strings. They are not assigned to Object references. They are called "orphan Objects" because nobody can access them.
Animal a = new Bird();
This means 3 steps: 1) Declare a variable with a type of Animal; 2) Create a Bird (Animal) according to the shape of a bird, using key word "new"; 3) Assign this Bird(Animal) to variable a. "a" is a kind of reference.
In Java, to judge where two Object references point to the same Objects or not,
we use the operator ==. This is called "shallow comparison".
Now on your issue. You created 2 Strings. However, your assignment is wrong. You did not follow the following rule: Assign an Object to an Object reference.
You created two Strings. They are not assigned to Object references. They are called "orphan Objects" because nobody can access them.