/**
* @Author: bi xuan
* @Date: 3/11/2021 9:12 AM
* @Description:
**/
public class Test {
public static void main(String[] args) {
Integer integer = new Integer(129);
Long aLong = new Long(129);
if (integer.equals(aLong))
System.out.println("true");
if (integer.equals(aLong.intValue()))
System.out.println("true 2");
}
}
仔细看源码,发现只有两个对象为integer才会进行拆箱操作进行比较