public class Main {
public static void main(String[] args) {
System.out.println(String.class.getClassLoader());
System.out.println(Main.class.getClassLoader());
}
}
分别输出null和AppClassLoader,为什么String是null?自己写的类即classpath下的是通过AppClassLoader加载,jdk里的类是通过哪个加载器加载的?
String’s class loader is bootstrap class loader. Class loading in this way will be displayed as null
String is loaded by the bootstrap class loader, and
引导类加载器
is implemented in native C++ code and does not inherit from java.lang.ClassLoader. We cannot obtain this class loader in the program of.