编辑代码

package Lyipion;

public class Lyipion {
	private int id;
	private String name;
	private double salary;

	public Lyipion(int id, String name, double salary) {
		super();
		this.id = id;
		this.name = name;
		this.salary = salary;
	}

	public Lyipion() {
		super();
	}

	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;
	}
	
	
}




package Lyipion;

import java.util.ArrayList;
import java.util.List;

public class Lyipion {

	public static void main(String[] args) {
		// 定义ArrayList对象
		List<Employee> list = new ArrayList<>();
		// 创建三个Employee类的对象
		Employee e1 = new Employee(1, "张三", 5000.0);
		Employee e2 = new Employee(2, "李四", 5500.0);
		Employee e3 = new Employee(3, "赵六", 4000.0);
		// 添加员工信息到ArrayList中
		list.add(e1);
		list.add(e2);
		list.add(e3);
		// 显示员工的姓名和薪资
		System.out.println("员工姓名   员工薪资");
		for (Employee e : list) {
			System.out.println(e.getName() + "           " + e.getSalary());
		}
	}
}