我正在尝试打印出带有整数键和员工值的树形图。每个 Employee 对象应该包含一个(字符串)姓氏、一个(字符串)名字、一个(整数)ID 和一个(字符串)绩效等级。我已经完成了员工课程。但是,我的输出带有作为位置的值。
Map(Integer, Employee) e = new TreeMap(Integer, Employee) ();
Employee e1 = new Employee("Puppy", "Nguyen", new Integer(345), "4");
e.put(e1.getID(), e1);
Employee e2 = new Employee("Kitty", "Thompsons", new Integer(123), "2");
e.put(e2.getID(), e2);
Employee e3 = new Employee("Cubby", "Gonzalez", new Integer(234), "5");
e.put(e3.getID(), e3);
System.out.println("Original Employee-typed TreeMap: ");
for(Map.Entry<Integer, Employee> entry : e.entrySet())
{
System.out.println("ID: " + entry.getKey());
System.out.println("Employee: " + entry.getValue());
}
我的输出:
原始员工类型的 TreeMap:
编号:123
员工:Employee@fef18a5d
编号:234
员工:Employee@ec71836a
编号:345
员工:Employee@89120ee