这个代码怎么改
eclipse吧
全部回复
仅看楼主
level 1
package gyd;
public class exe1 {
public static void main(String[] args) {
// TODO Auto-generated method stub
public class Student {//定义Student类
long xuehao, banji;//定义学号,班级变量
int age;//定义年龄变量
String name, sex;//定义名字,性别
public Student() {//构建方法
age = 18;//修改变量
}
public long getXuehao(long xuehao) {//创建获得学号的方法
return xuehao;//返回学号的值
}
public long getBanji(long banji) {//创建获得班级的方法
return banji;//返回班级的值
}
public int getAge() {//创建获得年龄的方法
return age;//返回年龄的值
}
public String getName(String name) {//创建获得名字的方法
return name;//返回名字的值
}
public String getSex(String sex) {//创建获得性别的方法
return sex;//返回性别的值
}
}
public class TestStudent{//
public static void main(String[] args) {//测试类
Student k = new Student();//创建Student的对象k
System.out.println("他现在" + k.getAge() + "岁了");//输出年龄
}
}
}
}
2022年10月26日 02点10分 1
1