package SecondJsp;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
public class EmployeeDome {
public static void main(String[] args) {
Employee zhangSan = new Employee("张三", 5000.0);
Employee liSi = new Employee("李四", 5500.0);
Employee wangWu = new Employee("王五", 4000.0);
Collection c = new ArrayList();
c.add(zhangSan);
c.add(liSi);
c.add(wangWu);
System.out.println("员工姓名 员工薪资");
Iterator it = c.iterator();
while(it.hasNext()) {
Object o = it.next();
System.out.println(o);
}
}
}
class Employee {
private int id;
private String name;
private double salary;
public Employee() {
}
public Employee(String name, double salary) {
this.name = name;
this.salary = 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 String toString() {
return this.name + "\t" + this.salary;
}
}