/*
不理解倒数第四行出什么问题了。
*/
class Worker
{
private int age;
private String name;
public Worker(){}
public Worker(int age,String name){
this.name = name;
this.age = age;
}
public void setName(String name){
this.name =name;
}
public String getName(){
return name;
}
public void setAge(int age){
this.age = age;
}
public int getAge(){
return age;
}
public void show(){
System.out.println("工人的名字是:"+name+"\t"+"年龄是:"+age);
}
}
class Demo
{
public static void main(String[] args){
Worker w = new Worker();
w.Worker(24,"林立");
w.show();
}
} |