举例子
Integer num1 = 10;
Integer num2 = 10;
System.out.println(num1 == num2); // true
Integer num3 = 200;
Integer num4 = 200;
System.out.println(num3 == num4); // false
Integer num5 = new Integer(10);
Integer num6 = new Integer(10);
System.out.println(num5 == num6); // false
System.out.println(num5.equals(num6)); // true
1. 判断是否相等使用 equals()
2. 判断大小 compareTo()方法
for (Character character : targetMap.keySet()) {
if (targetMap.get(character).compareTo(map.getOrDefault(character, -1)) > 0){
return false;
}
}
标签:10,num5,System,println,不能,Integer,比较,out
From: https://www.cnblogs.com/aclq/p/17676743.html