第六题
5. (List)已知有一个Worker 类如下:
public class Worker
{ private int age;
private String name;
private double salary;
public Worker (){}
public Worker (String name, int age, double salary)
{ this.name = name;
this.age = age;
this.salary = salary; }
public int getAge() { return age; }
public void setAge(int age) { this.age = age; }
public String getName() { return name; }
public void setName(String name) { this.name = name; }
public double getSalary(){ return salary; }
public void setSalary(double salary){ this.salary = salary; }
public void work(){
System.out.println(name + “ work”); } }
完成下面的要求
1) 创建一个List,在List 中增加三个工人,基本信息如下:
姓名 年龄 工资
zhang3 18 3000
li4 25 3500
wang5 22 3200<