Best way to check if <code>s</code> is null or empty
- Acheck_circle
s == null || s.length() == 0
- B
s == ""
- C
s.equals(null) || s.equals("")
- D
s.length() == 0 (NPE if null)
Explanation
Short-circuit: check null first; works regardless of state.
AP Computer Science A· difficulty 3/5
Best way to check if <code>s</code> is null or empty
s == null || s.length() == 0
s == ""
s.equals(null) || s.equals("")
s.length() == 0 (NPE if null)
Explanation
Short-circuit: check null first; works regardless of state.
Want 10 more like this — adaptive to your weak spots?