if (s != null & s.length() > 0) {
System.out.println(s);
}What is wrong?
- A
Nothing is wrong
- B
length() should be length
- Ccheck_circle
Single & does not short-circuit; replace with && to avoid NullPointerException
- D
& should be |
Explanation
The bitwise & evaluates both operands. When s is null, s.length() throws NullPointerException; && short-circuits and avoids the call.