Why aren't the relational operator (==) and the .equals method interchangeable? Why isn't the following code correct?
String myName = "Ken";
if (myName == "Ken")
The "==" operator and the .equals method are not interchangeable.
"==" operator is to compare the references of two variables, .equals method is to compare the value of the two objects.
In your example, ...
This response provides a tutorial correcting the relational operation and the .equals method.