Java Reference
In-Depth Information
{
System.out.println(“Changing name for “ + e.getName());
e.setName(name);
System.out.println(“New name is “ + e.getName());
}
public void updateAddress(EmployeeInfo e, String address)
{
System.out.println(“Changing address for “ + e.getName());
e.setAddress(address);
System.out.println(“New address is “ + e.getAddress());
}
}
The following HRDemo program instantiates a HumanResources object
and demonstrates changing an employee's name and address. Study the pro-
gram and try to determine its output, which is shown in Figure 10.9.
public class HRDemo
{
public static void main(String [] args)
{
Employee e = new Employee(“George Washington”, “Mt. Vernon”);
HumanResources hr = new HumanResources();
System.out.println(hr.getInfo(e) + “\n”);
hr.changeName(e, “Bill Gates”);
hr.updateAddress(e, “Redmond, WA”);
System.out.println(“\n” + hr.getInfo(e));
}
}
Figure 10.9
The output of the HRDemo program.
Search WWH ::




Custom Search