定义测试类TextStu1,在类的main()方法中创建Student类(实验8中定义的)的数组型实例对象。public class Student {public static int iCounter=0;
String sName;
String bGender;
String iAge;
String dHeight;
String dWeight;public static void getCounter() {System.out.println("学生总数:"+ ++iCounter);}public void getInfo(){
System.out.print("姓名:"+sName);
System.out.print(" 性别:"+bGender);
System.out.print(" 年龄:"+iAge+"岁");
System.out.print(" 身高:"+dHeight+"厘米");
System.out.println(" 体重:"+dWeight+"公斤");
}
public void setInfo(String n,String g,String a,String h,String w){
sName=n;
bGender=g;
iAge=a;
dHeight=h;
dWeight=w;
}
public Student() {
}
public Student(String n,String g,String a,String h,String w) {
sName=n;
bGender=g;
iAge=a;
dHeight=h;
dWeight=w;
}}
添加回答
举报
0/150
提交
取消