`
erylee
  • 浏览: 108283 次
社区版块
存档分类
最新评论

Ugly feature in Java5.0: int and Integer

    博客分类:
  • Java
阅读更多
陆续把我的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:(
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics