24-2 show构造方法

package zuoye1;

public class Employee {
private String name;
private int id;
private double salary;
public Employee(){
System.out.println("无参");
}
public Employee(String name,int id,double salary){
this.name=name;
this.id=id;
this.salary=salary;
}
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 geySalary(){
return salary;
}
public void setSalary(double salary){
this.salary=salary;
}
public void show(){
System.out.println("姓名 "+name+" 工号 "+id+" 工资 "+salary);
}

}

package zuoye1;

public class Testdome {
public static void main(String[] args){
Employee a=new Employee("按时打算",26,20000);
a.show();
}
}

原文地址:https://www.cnblogs.com/hfew/p/10550085.html