Look at the following code sections. Each of them demonstrates a bug in Java language (5 and 6).
Both bugs are related to in-boxing/out-boxing problems.
// BUG #1
publicclass CuriousJavaBug1 {
publicstaticvoid main(String[] str) {
Integer a = 100;
Integer b = 100;
Integer c = 200;
Integer d = 200;
System.out.println( a == b ); // true
System.out.println( c == d ); // false
}
}
// BUG #2
publicclass CuriousJavaBug2 {
// A nonsense from math's standpoint
publicstaticvoid main(String[] str) {
Integer a = new Integer(100);
Integer b = 100;
System.out.println( a <= b ); // true
System.out.println( a >= b ); // true
System.out.println( a == b ); // false
}
}