joh*_*ohn 3 java collections map
给出如下地图:
Map<String, Integer> = new Hashmap<String, Integer>;
Run Code Online (Sandbox Code Playgroud)
我怎样才能获得Collection<Integer>entrySet的任何(Collection的任何实现)?做.entrySet()似乎不起作用.
这取决于你是否真的想要一个SET.如果你想要一个真正的Set,你必须做:
Set mySet = new HashSet(map.values());
Run Code Online (Sandbox Code Playgroud)
请注意,值给出了一个可以有重复条目的Collection.
| 归档时间: |
|
| 查看次数: |
12427 次 |
| 最近记录: |