package com.lm.multest;
import java.util.HashMap;
import java.util.Map;
class Employee{
private String name;
private double salary;
public Employee(String n){
this.name = n;
this.salary = 0;
}
public String toString(){
return "[name="+this.name+",salary="+this.salary+"]";
}
}
public class Test {
public static void main(String[] args) {
Map<String,Employee> staff = new HashMap<String,Employee>();
staff.put("1", new Employee("Amy Lee"));
staff.put("2", new Employee("Harry"));
staff.put("3", new Employee("Gary"));
staff.put("4", new Employee("Cruz"));
System.out.println(staff);
staff.remove("1");
staff.put("2", new Employee("Lee Harry"));
System.out.println(staff);
for(Map.Entry<String, Employee> entry:staff.entrySet()){
String key = entry.getKey();
Employee value = entry.getValue();
System.out.println("key="+key+",value="+value);
}
}
}