In Java, what does "Hello" == new String("Hello") evaluate to?
Correct answer
A. false
14 views
A. false
14 views
== compares references, not content. new String always creates a separate object outside the string pool, so the result is false. Use .equals() to compare text.
Asked in: NTS, OCA Java, Technical Interviews
Not sure why the answer is A? Ask here and get an explanation.