Hi
The following code always throws a NullPointerException:
public static void main(String[] args) {
getInt(true);
}
public static int getInt(boolean b) {
return b?null:0;
}
I don’t understand why it is considered valid by the compiler. If I try to always return null, it does not compile. I don’t use autoboxing, I have just found this kind of code in the source code of someone else.
How does it work in Java 1.7? I still use Java 1.6.
Edit.: I use the OpenJDK.
