java中Integer面试的坑

class Test{
    
    public static void main(String[] args){
           //当值在[-128,127]中,不创建新的Integer

            Integer f1 = 100,f2 = 100,f3 = 150, f4 = 150;
            System.out.println(f1 == f2); //true
            System.out.println(f3 == f4); //false
}

}

 

posted @ 2019-06-19 16:34  y-xs  阅读(633)  评论(0编辑  收藏  举报