Class.forName:返回与给定的字符串名称相关联类或接口的Class对象。Class.forName是一个静态方法,同样可以用来加载类。
classforname的形式
该方法有两种形式:Class.forName(Stringname,booleaninitialize,ClassLoaderloader)和Class.forName(StringclassName)。第一种形式的参数name表示的是类的全名;initialize表示是否初始化类;loader表示加载时使用的类加载器。第二种形式则相当于设置了参数initialize的值为true,loader的值为当前类的类加载器。
staticClass>
forName(StringclassName)
ReturnstheClassobjectassociatedwiththeclassorinterfacewiththegivenstringname.
staticClass>
forName(Stringname,booleaninitialize,ClassLoaderloader)
ReturnstheClassobjectassociatedwiththeclassorinterfacewiththegivenstringname,usingthegivenclassloader.
classforname的说明:
publicstaticClass>forName(StringclassName)
ReturnstheClassobjectassociatedwiththeclassorinterfacewiththegivenstringname.Invokingthismethodisequivalentto:
Class.forName(className,true,currentLoader)
wherecurrentLoaderdenotesthedefiningclassloaderofthecurrentclass.
Forexample,thefollowingcodefragmentreturnstheruntimeClassdescriptorfortheclassnamedjava.lang.
上一篇:nginx支持socket转发吗
下一篇:编程开发中集成测试是什么意思