package other;
public class Employee {
private int id;
private String name;
private double salary;
public Employee(int id, String name, double salary) {
super();
this.id = id;
this.name = name;
this.salary = salary;
}
public Employee() {
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
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 class EmployeeTest {
public static void main(String[] args) {
List<Employee> list = new ArrayList<Employee>();
Employee emp1 = new Employee(1,"张三",5000);
Employee emp2 = new Employee(2,"李四",5500);
Employee emp3 = new Employee(3,"赵六",4000);
list.add(emp1);
list.add(emp2);
list.add(emp3);
System.out.printf("员工姓名 ");
System.out.printf("员工薪资");
System.out.println();
for (Employee emp:list) {
System.out.print(((Employee)emp).getName() + " ");
System.out.print(((Employee)emp).getSalary());
System.out.println();
}
}
}