I recently stumbled on a question that made me stop and think...
To me, the code below should always trigger an error, but when one of my colleagues asked me why Eclipse didn't show one, I couldn't answer anything.
class A {
public static void main(String... args) {
System.out.println(new Object() == 0);
}
}
I've investigated and found that with source level 1.6 it indeed throws an error:
incomparable types: Object and int
But now in 1.7 it compiles ok.
Please, what new feature does warrant this behavior?
new Object() == null
and thatnew Object() == 2
still triggers an error? – Profitsharing