I need to print the details of the employee that the user inputs. So far all I can get is the name. Can anyone give me a hand with this?
EmployeeStore
public void add(Employee employee)
{
map.put(employee.getEmployeeName(), employee);
}
public Employee searchByName(String name)
{
System.out.println(name);
return map.get(name);
}
Usage
EmployeeStore Store = new EmployeeStore();
Store.add(new Employee ("James O' Carroll", 18,"hotmail.com"));
Store.add(new Employee ("Andy Carroll", 1171,"yahoo.com"));
Store.add(new Employee ("Luis Suarez", 7,"gmail.com"));
Store.searchByName("James O' Carroll");
You are printing the key, not the value stored at the key.
public Employee searchByName(String name)
{
Employee employee = map.get(name);
System.out.println(employee.toString());
return employee;
}
Assuming the Employer class has defined a toString() method.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.