class Student
{
private String id;
private String name;
private char sex;
private double score;
Student(String sid,String cname,char csex,double cscore)
{
id=sid;
name=cname;
sex=csex;
score=cscore;
}
void studPrint()
{System.out.println("编号:"+id+"姓名:"+name+"\t性别:"+sex+"\t学习平均成绩:"+score);}
}
public class Exam5_3{
void run(){
Student stu[]=new Student[7];
stu[0]=new Student("20050701001","李小平","男",490);
stu[1]=new Student("20050701002","杨健","男",480);
stu[2]=new Student("20050701003","杨洁","男",470);
stu[3]=new Student("20050701004","刘老海","男",460);
stu[4]=new Student("20050701005","张忠","男",450);
stu[5]=new Student("20050701006","萧黎明","男",440);
stu[6]=new Student("20050701007","廖云龙","男",430);
int n=stu.length;
for(int i=n-1;i>=0;i--)
stu[i].stuDisp();
}
public static void manin(String args[]){
Exam5_3 ee=new Exam5_3();
ee.run();
}
}请问各位 为什么 Student 报错说找不到符号 ?
我看了很多遍都没看出来哪里有问题
{
private String id;
private String name;
private char sex;
private double score;
Student(String sid,String cname,char csex,double cscore)
{
id=sid;
name=cname;
sex=csex;
score=cscore;
}
void studPrint()
{System.out.println("编号:"+id+"姓名:"+name+"\t性别:"+sex+"\t学习平均成绩:"+score);}
}
public class Exam5_3{
void run(){
Student stu[]=new Student[7];
stu[0]=new Student("20050701001","李小平","男",490);
stu[1]=new Student("20050701002","杨健","男",480);
stu[2]=new Student("20050701003","杨洁","男",470);
stu[3]=new Student("20050701004","刘老海","男",460);
stu[4]=new Student("20050701005","张忠","男",450);
stu[5]=new Student("20050701006","萧黎明","男",440);
stu[6]=new Student("20050701007","廖云龙","男",430);
int n=stu.length;
for(int i=n-1;i>=0;i--)
stu[i].stuDisp();
}
public static void manin(String args[]){
Exam5_3 ee=new Exam5_3();
ee.run();
}
}请问各位 为什么 Student 报错说找不到符号 ?
我看了很多遍都没看出来哪里有问题
stu[i].stuDisp(); 应该是stu[i].studPrint()吧
还有main也打错了。。
这个类的构造函数和你创建实例给的参数不一致:
new Student("20050701001","李小平","男",490);
应为:
new Student("20050701001","李小平",'男',490);
这样肉眼去找,太累了