Java集合框架的四个接口https://blog.csdn.net/shunfa888/article/details/79832291

public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; Person other = (Person) obj; if (age != other.age) return false; if (id != other.id) return false; if (name == null) { if (other.name != null) return false; } else if (!name.equals(other.name)) return false; return true; }
Set<Person> set = new TreeSet<Person> (new Comparator( ){ public int compare(Person p1, Person p2){ return p1.getId( ) - p2.getId( ); } });
Set<Person> set = new TreeSet<Person>(new Compare( )); class Compare implements Comparator( ){ 重写compare方法。 }
第一种
Set<String> keys =map1.keySet(); Iterator<String> iter=keys.iterator(); while (iter1.hasNext()) { String key=iter.next(); System.out.println(key+"----"+map.get(key)); }
第二种
Collection<String> va=map.values(); Iterator<String> iter=va.iterator(); while (iter.hasNext()) { System.out.println(iter.next()); }
第三种
Set<Entry<String,String>> set= map.entrySet(); Iterator<Entry<String, String>> iter=set.iterator(); ① while (iter.hasNext()) { Entry<String, String> entry=iter.next(); //entry是Java给我们提供的一种特殊的数据类型 其实就是一个键值对 //键就是当前这条记录的键,使用getkey()取到 //值就是当前这条记录的值,使用getValue()取到 System.out.println(entry.getKey()+""+entry.getValue()); } ② for(Entry<String, String> y:set){ System.out.println(y.getKey()+"----"+y.getValue()); }
http://www.wqv1289.top/
http://www.mxz6626.top/
http://www.npl2536.top/
http://www.vme0237.top/
http://www.edr0603.top/
http://www.kft8502.top/
http://www.kwb2561.top/
http://www.dqv1869.top/
http://www.iai9521.top/
http://www.jla2696.top/
http://www.vip1477.top/
http://www.ryc2010.top/
http://www.tpz5308.top/
http://www.gzi6562.top/
http://www.dwf8840.top/
http://www.soq5741.top/
http://www.pud6117.top/
http://www.zrv3166.top/
http://www.ylg5948.top/
http://www.evm5267.top/
http://www.mmc0244.top/
http://www.auk8793.top/
http://www.nbw1542.top/
http://www.oka2713.top/
http://www.txz2284.top/
http://www.amv5754.top/
http://www.ubb2737.top/
http://www.oim9564.top/
http://www.jhg1176.top/
http://www.ehe5445.top/
http://www.vkp0211.top/
http://www.uzy8206.top/
http://www.cnn5986.top/
http://www.nwz4782.top/
http://www.qndfr.org/
http://www.zcshr.org/
http://www.fnfdf.cc/
http://www.taoshun1688.com/
https://card.weibo.com/article/v3/editor#/history/186608
https://card.weibo.com/article/v3/editor#/history/186424
https://card.weibo.com/article/v3/editor#/history/185801
https://card.weibo.com/article/v3/editor#/history/185781
https://card.weibo.com/article/v3/editor#/history/185463
https://card.weibo.com/article/v3/editor#/history/174288
https://card.weibo.com/article/v3/editor#/history/174119
https://card.weibo.com/article/v3/editor#/history/173561
https://card.weibo.com/article/v3/editor#/history/173336
https://card.weibo.com/article/v3/editor#/history/173082
https://card.weibo.com/article/v3/editor#/history/184630
https://card.weibo.com/article/v3/editor#/history/183057
https://card.weibo.com/article/v3/editor#/history/184940
https://card.weibo.com/article/v3/editor#/history/186882
https://card.weibo.com/article/v3/editor#/history/186884
https://card.weibo.com/article/v3/editor#/history/186966
https://card.weibo.com/article/v3/editor#/history/187201
https://card.weibo.com/article/v3/editor#/history/187391
https://card.weibo.com/article/v3/editor#/history/174940
https://card.weibo.com/article/v3/editor#/history/187695
https://card.weibo.com/article/v3/editor#/history/185492
https://card.weibo.com/article/v3/editor#/history/187410
https://card.weibo.com/article/v3/editor#/history/174972
https://card.weibo.com/article/v3/editor#/history/187714
https://card.weibo.com/article/v3/editor#/history/185531
https://card.weibo.com/article/v3/editor#/history/188021
https://card.weibo.com/article/v3/editor#/history/175465
https://card.weibo.com/article/v3/editor#/history/187712
https://card.weibo.com/article/v3/editor#/history/188523
https://card.weibo.com/article/v3/editor#/history/188120
https://card.weibo.com/article/v3/editor#/history/176032
https://card.weibo.com/article/v3/editor#/history/176073
https://card.weibo.com/article/v3/editor#/history/176022
https://card.weibo.com/article/v3/editor#/history/188239
https://card.weibo.com/article/v3/editor#/history/188643
https://card.weibo.com/article/v3/editor#/history/186373
https://card.weibo.com/article/v3/editor#/history/188251
https://card.weibo.com/article/v3/editor#/history/188665
https://card.weibo.com/article/v3/editor#/history/186385
https://card.weibo.com/article/v3/editor#/history/186508
https://card.weibo.com/article/v3/editor#/history/188788
https://card.weibo.com/article/v3/editor#/history/188382
https://card.weibo.com/article/v3/editor#/history/186627
https://card.weibo.com/article/v3/editor#/history/176292
https://card.weibo.com/article/v3/editor#/history/176523
https://card.weibo.com/article/v3/editor#/history/188817
https://card.weibo.com/article/v3/editor#/history/188818
https://card.weibo.com/article/v3/editor#/history/189232
https://card.weibo.com/article/v3/editor#/history/189237
https://card.weibo.com/article/v3/editor#/history/186919
https://card.weibo.com/article/v3/editor#/history/186921
https://card.weibo.com/article/v3/editor#/history/176408
https://card.weibo.com/article/v3/editor#/history/188683
https://card.weibo.com/article/v3/editor#/history/189175
https://card.weibo.com/article/v3/editor#/history/186813
https://card.weibo.com/article/v3/editor#/history/176522