JAVA类里面定义类 java中定义类的方法_java

package lesson03;

public class demo08 {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Employee emp = new Employee("贾树行",006,1222);
		//调用
		emp.say();
		

	}

}
//定义员工类
class Employee{
	private String name;
	private int id;
	private double salary;
	//有参
	public Employee(String name, int id, double salary) {
		this.name = name;
		this.id = id;
		this.salary = salary;
	}
	//空参
	public Employee() {
	
	}
	//get,set方法

	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public int getId() {
		return id;
	}
	public void setId(int id) {
		this.id = id;
	}
	public double getSalary() {
		return salary;
	}
	public void setSalary(double salary) {
		this.salary = salary;
	}
	public void say() {
		System.out.println("姓名:"+name+"编号:"+id+"工资:"+salary);
	}
	
	
}