java.util.HashMap #27
Replies: 1 comment
-
public final class Integer {
// ...
public boolean equals(Object obj) {
if (obj instanceof Integer) {
return value == ((Integer)obj).intValue();
}
return false;
}
// ...
}25.13中的注意部分. get方法内部通过key查找对应的value时,key用的是equals方法比较. 一.基本类型调用会自动包装. 二.包装类重写了equals方法,取基本类型值进行比较. 所以对于同一种基本类和包装类来说. 这样使用map是可以的. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
java.util.HashMap
https://diguage.github.io/jdk-source-analysis/java.util.HashMap.html
Beta Was this translation helpful? Give feedback.
All reactions