标签:
package jihe; public class Emp { private String Id; private String Name; public Emp(String id, String name) { Id = id; Name = name; } public String Iemp() { return Id; } public String Emp() { return Name; } }
//14.7.3 Emp our1 = new Emp("012", "哈哈"); Emp our2 = new Emp("013", "呵呵"); Emp our3 = new Emp("014", "嘿嘿"); Emp our4 = new Emp("015", "哼哼"); Emp our5 = new Emp("016", "呼呼"); TreeMap<String, String> stu = new TreeMap<>(); stu.put(our1.Iemp(), our1.Emp()); stu.put(our2.Iemp(), our2.Emp()); stu.put(our3.Iemp(), our3.Emp()); stu.put(our4.Iemp(), our4.Emp()); stu.put(our5.Iemp(), our5.Emp()); Set<String> t = stu.keySet(); for(String s : t) { System.out.println(s+stu.get(s)); } System.out.println(); stu.remove("015"); Set<String> ct = stu.keySet(); for(String s : t) { System.out.println(s+stu.get(s)); }
标签:
原文地址:http://www.cnblogs.com/wgbs25673578/p/4886547.html