解决方案 »
- protected Class<? extends Enum> enumClass;中的问号是什么意思?
- 谁能告诉我repaint方法和update方法究竟是干什么用的
- public、private、static都不能修饰局部变量
- Integer i = new Integer(0);的打印结果?
- java 播放器 波形图 进度条 动态图片
- 怎么把字符串1,000,000.00转换成double型
- 从access中取出时间比较,出错?
- 请教:如何使对话框弹出是位于最顶层(在线)
- JAVA程序员的薪水到底应为几何!!!大家来讨论!!
- 关于双缓冲绘图的困扰 求大神帮助
- Object _getClass
- Javaweb工程转化为Java工程web.xml怎么处理?
* Returns a {@link Set} view of the keys contained in this map.
* The set's iterator returns the keys in ascending order.
* The set is backed by the map, so changes to the map are
* reflected in the set, and vice-versa. If the map is modified
* while an iteration over the set is in progress (except through
* the iterator's own <tt>remove</tt> operation), the results of
* the iteration are undefined. The set supports element removal,
* which removes the corresponding mapping from the map, via the
* <tt>Iterator.remove</tt>, <tt>Set.remove</tt>,
* <tt>removeAll</tt>, <tt>retainAll</tt>, and <tt>clear</tt>
* operations. It does not support the <tt>add</tt> or <tt>addAll</tt>
* operations.
*/
public Set<K> keySet() {
return navigableKeySet();
}
TreeSet set = TreeMap.getKeySet();
这样 set 就是默认有序的
Iterator ir=map.keySet().iterator();//获取hashMap的键值,并进行遍历
while(ir.hasNext()){
Object key= ir.next();
System.out.println("键为"+key+"所对应的值为"+map.get(key));
}
即是通过TreeMap中指针的移动,实现对TreeMap的遍历
Set只保证元素的唯一性。
public interface NavigableSet<E> extends SortedSet<E>{......}