Suppose I have the following code:
class proba {
boolean fun(Number n) {
return n == null || 0 == n;
}
}
This compiles without problems using openjdk 7 (debian wheezy), but when using openjdk 8, the following error fails to compile (even when using-source 7):
proba.java:3: error: incomparable types: int and Number
return n == null || 0 == n;
^
1 error
How to get around this:
- Is there a compiler option for this construct to continue working in java 8?
- Should I do a lot of consecutive ifs with checking the instances of all subclasses of Number and casting, and then compare one by one? It seems ugly ...
- Other offers?
source
share