public class people{ private String name; private String sex; private int age; public Resume(){ //System.out.println(); }public Resume(String name,String sex,int age){ this.name=name; this.sex=sex; this.age=age; } public String getName(){ return name; } public String getSex(){ return sex; } public int getAge(){ return age; } public void include(){ System.out.println("姓名:"+this.getName()+"\n性别:"+this.getSex()+"\n年龄:"+this.getAge()); }} class Resume { public static void main(String[] agers){ Resume re=new Resume("李四","男",18); re.include(); } }
时间: 2023-05-27 22:05:45 浏览: 110
As an AI language model, I am unable to execute the code provided as it contains errors. The class name should be "People" instead of "Resume" as it conflicts with the constructor name. Also, the print statement in the include() method should have a "+" operator to concatenate the strings. Here is the corrected code:
public class People{
private String name;
private String sex;
private int age;
public People(){
//System.out.println();
}
public People(String name, String sex, int age){
this.name = name;
this.sex = sex;
this.age = age;
}
public String getName(){
return name;
}
public String getSex(){
return sex;
}
public int getAge(){
return age;
}
public void include(){
System.out.println("姓名:" + this.getName() + "\n性别:" + this.getSex() + "\n年龄:" + this.getAge());
}
}
class Resume {
public static void main(String[] agers){
People re = new People("李四", "男", 18);
re.include();
}
}
阅读全文