public static void main(String[] args) {
		
		Integer a=1;
		Integer b=2;
		Integer c=3;
		Integer d=3;
		Integer e=321;
		Integer f=321;
		Long g=3L;
		System.out.println(c==d);
		System.out.println(e==f);
		System.out.println(c==(a+b));
		System.out.println(c.equals(a+b));
		System.out.println(g==(a+b));
		System.out.println(g.equals(a+b));
}

数字==是比较值的,而包装类的"=="运算在没有遇到算术运算的情况下是不会拆箱的,而且它们的equals()方法不会处理数据转型的关系

相关文章:

  • 2021-06-26
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-03
  • 2021-11-21
猜你喜欢
  • 2021-11-14
  • 2021-11-14
  • 2021-12-04
  • 2022-12-23
  • 2021-10-18
  • 2021-04-21
  • 2022-12-23
相关资源
相似解决方案