public class OOTest01
{
public static void main(String[] args) {
Student s= new Student();
s.name="zhangsan";
s.no=18;
s.sex=false;
System.out.println(s.name);
System.out.println(s.no);
System.out.println(s.sex);
}
}
//以下为第二文件
public class Student
{
String name;
int no;
boolean sex;
}
运行之后会出现如下问题
Exception in thread "main" java.lang.IllegalAccessError: class OOTest01 tried to access field Student.name (OOTest01 is in unnamed module of loader com.sun.tools.javac.launcher.Main$MemoryClassLoader @799d4f69; Student is in unnamed module of loader 'app')
at OOTest01.main(OOTest01.java:5)

大佬们帮帮忙吧,实在搞不懂了。
- 写回答
- 好问题 0 提建议
- 关注问题
- 邀请回答
-
7条回答 默认 最新
- 无厘头编程 2021-01-02 16:03关注
运行没有问题。用的是 IntelliJ IDEA Community Edition 2020.2
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报