源代码如下:
public class Test {
public static void main(String[] args){
Son s=new Son();
s.show();
}
}
public class Father{
public int age=50;
}
public class Son extends Father{
public int age=19;
public void show(){
int age=39;
System.out.println(age);
System.out.println(this.age);
System.out.println(super.age);
}
}
问题如下:
Father.java is not on the classpath of project java源代码字节码文件夹_4af54545, only syntax errors are reported
Son.java is not on the classpath of project java源代码字节码文件夹_4af54545, only syntax errors are reported
Test.java is not on the classpath of project java源代码字节码文件夹_4af54545, only syntax errors are reported
请问如何解决?
如果你是用cmd运行的,那要先进去.java文件的上一级目录
public的类需要有各自的java文件
https://www.cnblogs.com/zhukunqiang/p/6652787.html
请问你是怎么执行的,用编辑器还是cmd命令界面执行。
三个文件是否在同一个目录下。