Test.java
public class Test{
public static void main(String []args){
Student student = new Student();
student.showData();
}
}
Student.java
class Student{
private int score = 100;
private String name = "Alex";
public void showData(){
System.out.printf("name: %s score: %s\n", name, score);
}
}
when I Compile the code above I always get a error say
.\Test.java:3: error: cannot find symbol
Student student = new Student();
^
symbol: class Student
location: class Test
.\Test.java:3: error: cannot find symbol
Student student = new Student();
^
symbol: class Student
location: class Test
2 errors
but when I copy the code from Student into Test and it work. So I want to know why can Someone help me? please. I using cmd from windows11
PS D:\test> ls
目錄: D:\test
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a---- 2021/11/18 下午 09:44 637 Student.class
-a---- 2021/11/18 下午 06:30 165 Student.java
-a---- 2021/11/18 下午 09:48 128 Test.java
PS D:\test> javac .\Student.java
PS D:\test> javac .\Test.java
.\Test.java:3: error: cannot find symbol
Student student = new Student();
^
symbol: class Student
location: class Test
.\Test.java:3: error: cannot find symbol
Student student = new Student();
^
symbol: class Student
location: class Test
2 errors