Java程序设计项目化教程_7.5.5 TreeMap.pptxVIP

  • 0
  • 0
  • 约3.05千字
  • 约 8页
  • 2026-03-25 发布于广东
  • 举报

7.5.5TreeMapHashMap集合存储的元素的键值是无序且不可重复的,为了对集合中的元素的键值进行排序,Map接口提供了另一个可以对集合中元素键值进行排序的实现类TreeMap。

例7-25TreeMap集合的用法importjava.util.Iterator;importjava.util.Set;importjava.util.TreeMap;publicclassexample7_25{publicstaticvoidmain(String[]args){ TreeMapmap=newTreeMap();//创建Map集合 map.put(3,菲菲);//存储键和值 map.put(2,小明); map.put(4,赵六); map.put(3,大明); SetkeySet=map.keySet(); Iteratorit=keySet.iterator(); while(it.hasNext()){ Objectkey=it.next(); Objectvalu

文档评论(0)

1亿VIP精品文档

相关文档