Discussion about a relational operator


Discuss the below:

Q: Why aren't the relational operator (==) and the .equals method interchangeable? Why isn't the following code correct?

String myName = "Ken";
if (myName == "Ken")

 

Solution Preview :

Prepared by a verified Expert
Basic Computer Science: Discussion about a relational operator
Reference No:- TGS01935112

Now Priced at $20 (50% Discount)

Recommended (90%)

Rated (4.3/5)