pre-knowledge
Remark
For String literals you work in the String Class, therefore you could use the equals method but you can also use the == operator.
CREATING A SITUATION WITH String literals
Adding some text to this space.. “ey bro”
SCENARIO’S
1. ONLY ONE SCENARIO COULD OCCUR FOR PRIMITIVE DATATYPES
If I want to compare the text, e.g. “ey bro” to the text “ey bro”, it is like a reference to itself
One could just use the == command because it is a reference to itself. However, because the text is saved in the String Class, you can also use the built-in function .equals().
| == |
| .equals() |