在学习对象的创建与使用的时候,遇到如下问题,
Exception in thread "main" java.lang.IllegalAccessError:class OOTest01 tried to access field Student.no (OOTest01 is in unnamed module of loader com.sun.tools.javac.launcher.Main$MemoryClassLoader @282003e1; Student is in unnamed module of loader 'app')
at OOTest01.main(OOTest01.java:29)
我的两个文件的代码分别如下:
OOTest01.java
public class OOTest01
{
public static void main(String[] args){
int i = 10;
Student s = new Student();
int stuNo = s.no;
String stuName = s.name;
boolean stuSex = s.sex;
int stuAge = s.age;
String stuAddr = s.addr;
System.out.println(stuNo);
System.out.println(stuName);
System.out.println(stuSex);
System.out.println(stuAge);
System.out.println(stuAddr);
}
}
Student.java
public class Student
{
int no = 0;
String name = null;
int age = 0;
boolean sex = false;
String addr = null;
}
请问这种情况如何解决