Why does the following Java code throw a NullPointerException?
public static void main(String[] args) {
getInteger(null);
}
public static Integer getInteger(Number n) {
return (n == null || n instanceof Integer) ? (Integer)n : n.intValue();
}
EDIT: I added parentheses to end the confusion about "whether I am sometimes returning a boolean".