小弟是一名JAVA初学者,今天学内部类的时候遇到这个问题,class Student123这里一直报错,说是已定义的类型,求解这是什么情况,该如何去解决?
public class StudentTest {
public static void main(String[] args){
Student123 S1=new Student123();
S1.setName("张三");
S1.setScore(80);
S1.setage(20);
System.out.println(S1.getName());
System.out.println(S1.getScore());
System.out.println(S1.getage());
}
}
class Student123{
private String name;
private double score=60;
private int age;
public String getName(){
return name;
}
public void setage(int age) {
this.age=age;
}
public int getage() {
return age;
}
public void setName(String name){
this.name=name;
}
public double getScore(){
return score;
}
public void setScore(double score){
if (score>60){
this.score=score;
}
}
}
非常感谢,其实这个问题也不知道什么情况,他是有时候报错有时候正常,我用的是Eclipse编译的
追答哦,我没用Eclipse,我用的是JCreator Pro5.00.016,呵呵。。。
刚才我也是,重启一下JCreator Pro就正常了。
但在dos里运行java是正常的。