package jihe;

public class Emp {

    private String id;
    
    private String name;
    
    public String getId()
    {
        return id;
    }
    
    public String getName()
    {
        return name;
    }
    
    public Emp(String id,String name)
    {
        this.id = id;
        this.name = name;
    }
}

 

HashMap<String,String> hm = new HashMap<>();
        
        Emp emp = new Emp("001","aaa");
        
        hm.put(emp.getId(), emp.getName());
        
        emp = new Emp("002","bbb");
        
        hm.put(emp.getId(), emp.getName());
        
        emp = new Emp("011","ccc");
        
        hm.put(emp.getId(), emp.getName());
        
        emp = new Emp("015","ddd");
        
        hm.put(emp.getId(), emp.getName());
        
        emp = new Emp("019","eee");
        
        hm.put(emp.getId(), emp.getName());
        
        hm.remove("015");
        
        Set<String> S = hm.keySet();
        
        for(String s4 : S)
        {
            System.out.println("Key:" + s4 +" Value:" + hm.get(s4));
        }
        
        

 

相关文章:

  • 2021-07-18
  • 2021-07-14
  • 2022-12-23
  • 2021-10-02
  • 2022-01-23
  • 2021-11-23
  • 2021-08-27
猜你喜欢
  • 2021-12-03
  • 2022-02-15
  • 2021-05-26
  • 2021-10-12
  • 2021-07-26
  • 2022-02-09
  • 2021-09-25
相关资源
相似解决方案