package com.dodoke;
import java.util.ArrayList;
import java.util.List;
public class EmployeeTest {
public static void main(String[] args) {
List list = new ArrayList();
Employee emp1 = new Employee(1,"张三",5000);
Employee emp2 = new Employee(1,"李四",5500);
Employee emp3 = new Employee(1,"赵六",4000);
list.add(emp1);
list.add(emp2);
list.add(emp3);
System.out.println("员工姓名 员工工资");
for(int i = 0;i< list.size();i++){
System.out.println(list.get(i));
}
}
}
package com.dodoke;
public class Employee {
private int id;
private String name;
private double salary;
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 Employee() {
super();
}
public Employee( String name, double salary) {
this.setName(name);
this.setSalary(salary);
}
@Override
public String toString() {
return " " + name + " " +salary;
}
}