求解释,为何输出都是 true ? 感谢
public static void main(String[] args) {
Integer int1 = new Integer(1);
Integer int2 = new Integer(1);
System.out.println(int1 >= int2); //true
System.out.println(int1 <= int2); //true
}
int1 和 int2 都是1,两都相等,所以无论是 >= 或 <= 等于都成立,所以是 true.
两个Integer 对象具有相同的值 ,都为1,在进行比较的时候是比较的它们的值 ,1 >= 1, 1 <= 1当然都为true