对于包装类型Integer的值比较与int的值比较是不同的;
 
public class Java_Val_Compare {

    public static void main(String[] args) {
        Integer a1 = 127;
        Integer a2 = 127;
        System.out.println("a1==a2?:\t"+(a1==a2));
        
        Integer b1 = 128;
        Integer b2 = 128;
        System.out.println("b1==b2?:\t"+(b1==b2));
    
        System.out.println("b1.intValue()==b2.intValue()?:\t"
        +(b1.intValue()==b2.intValue()));
    }
}

执行结果:

Java 包装类Integer的值比较

相关文章:

  • 2021-07-16
  • 2021-06-13
  • 2021-04-02
  • 2018-07-30
  • 2021-12-18
  • 2021-02-20
  • 2021-10-21
  • 2021-09-19
猜你喜欢
  • 2021-04-24
  • 2022-01-11
  • 2021-11-22
  • 2019-03-28
  • 2021-05-18
  • 2021-10-03
  • 2021-12-28
  • 2021-08-18
相关资源
相似解决方案