Class.forName() and ClassLoader.loadClass()

来源:互联网 发布:销售公司软件 编辑:程序博客网 时间:2024/05/22 15:36

Class. forName(String className) throws ClassNotFoundException
Returns the Class object associated with the class or interface with the given string name. Invoking this method is equivalent to:
  Class.forName(className, true, currentLoader)
 
当调用这个方法的时候, 将会完成类的初始化工作.

 

这也是jdbc 应用中常见的, Class.forName("... driver");

 

ClassLoader.loadClass(); 不会做类的初始化工作,只是将class load到jvm中.

原创粉丝点击