标签:string span str out put 链表实现 arraylist java div
List 用数组实现
Set 用链表实现
MAP 用数据加链表实现
map 输出
Map<String, String> map = new HashMap<String, String>(); map.put("a", "1"); map.put("b", "2"); map.put("c", "3"); Set<Map.Entry<String, String>> set2 = map.entrySet(); /* for (Map.Entry<String, String> entry: map.entrySet()) { System.out.println(entry.getKey()+":"+entry.getValue()); }*/ List<Map.Entry<String, String>> list = new ArrayList<Map.Entry<String, String>>(set2); Collections.sort(list,new Comparator<Map.Entry<String, String>>(){ public int compare(Entry<String, String> o1, Entry<String, String> o2) { if(o1.getKey().compareTo(o2.getKey())>1){ return 1; }else if(o1.getKey().compareTo(o2.getKey())<1){ return -1; } return 0; } }); for (Entry<String, String> entry : list) { System.out.println(entry.getKey()+":"+entry.getValue()); }
标签:string span str out put 链表实现 arraylist java div
原文地址:http://www.cnblogs.com/jentary/p/6178805.html