Problems
Auto unboxing
Q. Which one is corrent?
Integer i = null;
if (i == 0) {
System.out.println("Zero");
} else {
System.out.println("Not Zero");
}
- Zero
- Not Zero
- Throws Exception
- None of above
Use Objects.equals(Object, Object) to compare objects.
Ref: JLS 15.21.1 Numerical Equality Operators == and !=