Ugly feature in Java5.0: int and Integer

陆续把我的Blog从cublog搬过来,那边没人讨论Java、JEE、Ruby等领域:)

Why more and more people prefer Ruby to Java? Because Sun is killing Java step by step..., I think, Java5.0 is the start...

Look the Ugly new feature in Java5.0 below,

import junit.framework.TestCase;

public class IntegerIntTest extends TestCase {

    public void testIntegerIntEq() {
        int i = 1;
        Integer intObj = i;
        assertTrue(intObj == i);
    }
   
    public void testIntegerIntNotEq() {
        int i = 1;
        Integer intObj = new Integer(i);
        assertTrue(i == intObj);
    }
   
    public void testIntegerObj() {
        int i = 1;
        Integer intObj1 = new Integer(i);
        assertTrue(intObj1 == i);
        Integer intObj2 = new Integer(i);
        assertTrue(intObj2 == i);
        //????!
        assertTrue(intObj2 == intObj1);
    } 
   
}

This feature breaks the transition law: If A==B and B==C, then A==C.

Sun's guys are making Java ugly and dirty... Maybe it's the time to enjoy the beauty of Ruby:(

你可能感兴趣的:(java,c,JUnit,Ruby,sun)