public class student {private String stuName;private int stuAge;private int stuNumber;public student(String name,int age,int number){ stuName=name; stuAge=age; stuAge=number;}public String getName(){ return stuName;}public int getAge(){ return stuAge;}public int getNumber(){ return stuNumber;} public static void main(String[] args) { student stu1=new student("张三",10,14) ;System.out.println("学生姓名:"+stu1.getName());System.out.println("学生年龄:"+stu1.getAge());System.out.println("学生学号:"+stu1.getNumber()); }}
1 回答
已采纳
摩诃迦叶
TA贡献146条经验 获得超54个赞
public student(String name,int age,int number) { stuName=name; stuAge=age; stuAge=number; }
这段写错了。
public student(String name,int age,int number) { stuName=name; stuAge=age; stuNumber=number; }
这样才对
添加回答
举报
0/150
提交
取消