Q. If you compile and execute an application with the following code in its main() method: Why ” s” is created two objects [duplicate]

The first s == "Computer" test will fail, since s and the literal string "Computer" are sitting at different addresses.

The second s.equals("Computer") will succeed. The two strings have equal contents.

Any good tutorial book on Java would explain that better than we have time to.

Leave a Comment