如代码所示:我不明白为什么在第一张图中,大小是100(remove()之后),但在第二张图中,大小是1而不是2。是不是因为数据类型的不同存储在哈希图中还是?
public class test {
public static void main(String[] args) {
Map<Short, String> map = new HashMap<Short, String>();
for (short i = 0; i < 100; i++) {
map.put(i, String.valueOf(i));
map.remove(i - 1);
}
Map<Integer, Integer> hashmap = new HashMap<>();
hashmap.put(3,4);
hashmap.put(4,5);
hashmap.remove(3);
System.out.println(hashmap.size());
System.out.println(map.size());
}
}
Run Code Online (Sandbox Code Playgroud)
帮我!
| 归档时间: |
|
| 查看次数: |
90 次 |
| 最近记录: |