To safely compare a string with a literal that might be null, use
- A
s.equals("yes")
- B
s == "yes"
- Ccheck_circle
"yes".equals(s) (avoids NPE if s is null)
- D
Both A and C work
Explanation
Calling <code>.equals</code> on the literal is a defensive idiom because the literal is never null.