大家讲讲TreeMap的使用,回答好的立刻给100分!!

xuii 2003-09-11 02:29:44
大家讲讲TreeMap的使用,回答好的立刻给100分!!
...全文
85 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
xuii 2003-09-11
  • 打赏
  • 举报
回复
这位兄弟水平不错啊.
JavaBoyCaoJi 2003-09-11
  • 打赏
  • 举报
回复
具体见
http://www.javaresearch.org/article/showarticle.jsp?column=1&thread=8766
JavaBoyCaoJi 2003-09-11
  • 打赏
  • 举报
回复
import java.util.*;public class ExampleHashMap { //calendar Map Map calendar = new HashMap(); //constructor to add all elements into Map public ExampleHashMap(String d[], String i[]){ for (int x=0; x<d.length; x++) calendar.put(d[x], i[x]); } //main method public static void main(String args[]) { //Data to be inserted into calendar String [] dates = {"10/31/01", "01/01/01", "03/05/01", "02/04/01"}; String [] items = {"Halloween", "New Years", "Birthday", "Anniversary"}; //create instance of class ExampleHashMap example = new ExampleHashMap(dates, items); //print out all key/value pairs in map System.out.println("map= " + example.calendar); //retrieve mappings into Set Set mappings = example.calendar.entrySet(); System.out.println("object \t\t\tkey\t\tvalue"); //iterate through mappings and print content for (Iterator i = mappings.iterator(); i.hasNext();) { Map.Entry me = (Map.Entry)i.next(); Object ok = me.getKey(); Object ov = me.getValue(); System.out.print(me + "\t"); System.out.print(ok + "\t"); System.out.println(ov); } }}
xuii 2003-09-11
  • 打赏
  • 举报
回复
回答的精辟的再多给200分也无所谓.

62,614

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧