今天在练习类加载器的时候!定义了一个类
- package com.wing;
- /*public*/ class A
- {
- @Override
- public String toString()
- {
- return "SSS";
- }
- }
复制代码
如果没有加public修饰符,会提示
Exception in thread "main" java.lang.IllegalAccessException: Class com.wing.Load
er can not access a member of class com.wing.A with modifiers ""
at sun.reflect.Reflection.ensureMemberAccess(Reflection.java:101)
at java.lang.Class.newInstance(Class.java:427)
at com.wing.Loader.main(Loader.java:28)
public在类上的作用是干嘛的? |