大家好,又见面了,我是你们的朋友全栈君。
Syntax:
句法:
public ClassLoader getClassLoader();
Parameter(s):
参数:
Return value:
返回值:
The return type of this method is ClassLoader, it returns the following values based on the given cases,
此方法的返回类型为ClassLoader ,它根据给定的情况返回以下值:
Example:
例:
// Java program to demonstrate the example
// of ClassLoader getClassLoader() method of Class
public class GetClassLoaderOfClass {
public static void main(String[] args) throws Exception {
// It returns the Class object attached with the given
//classname
Class cl = Class.forName("GetClassLoaderOfClass");
// By using getClassLoader() is to load the class
ClassLoader class_load = cl.getClassLoader();
// If any ClassLoader associate with the Class
if (class_load != null) {
Class load_class = class_load.getClass();
System.out.print("Associated Loader Class: ");
System.out.print(load_class.getName());
}
// No Loader associated with the class
else
System.out.println("No system loader associated with the class");
}
}
Output
输出量
Associated Loader Class: jdk.internal.loader.ClassLoaders$AppClassLoader
翻译自: https://www.includehelp.com/java/class-class-getclassloader-method-with-example.aspx
发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/146210.html原文链接:https://javaforall.cn