ClassLoader类findLoadedClass()方法 (ClassLoader Class findLoadedClass() method)

  • findLoadedClass() method is available in java.lang package.

    findLoadedClass()方法在java.lang包中可用。

  • findLoadedClass() method is used to return the Class with the given binary class name when this loader has been recorded by JVM as initializing the loader of the class with that binary name.

    当JVM在使用该二进制名称初始化类的加载器时记录了该加载器时,将使用findLoadedClass()方法返回具有给定二进制类名称的Class。

  • findLoadedClass() method is a non-static method, it is accessible with the class object only and if we try to access the method with the class name then we will get an error.

    findLoadedClass()方法是一个非静态方法,只能通过类对象访问,如果尝试使用类名称访问该方法,则会收到错误消息。

  • findLoadedClass() method may throw an exception at the time of loading Class object.

    在加载Class对象时, findLoadedClass()方法可能会引发异常。

Syntax:

句法:

    protected Class findLoadedClass(String class_name);

Parameter(s):

参数:

  • String class_name – represents the binary name of the class.

    字符串class_name –表示类的二进制名称。

Return value:

返回值:

The return type of this method is Class, it returns Class object when the class has been recorded otherwise it returns null, when the class has not been recorded.

该方法的返回类型为Class ,当记录了该类时,它将返回Class对象;否则,当未记录该类时,它将返回null。

Example:

例:

// Java program to demonstrate the example
// of Class findLoadedClass(String class_name)
// method of ClassLoader
class FindLoadedClass extends ClassLoader {void loadedClass() {// It checks whether the given class is loaded
// or not by using the findLoadedClass()
Class cl1 = super.findLoadedClass("java.lang.String");
// If cl1 not null that means cl1 is loaded
// then don't need to load again
if (cl1 != null)
System.out.println(" Class already loaded!!!");
else
System.out.println("Ready to load the given class by using loadClass()!!!");
}
}
public class Main {public static void main(String[] args) throws Exception {// Creating an instance of FindLoadedClass
FindLoadedClass lc = new FindLoadedClass();
lc.loadedClass();
}
}

Output

输出量

Ready to load the given class by using loadClass()!!!

翻译自: https://www.includehelp.com/java/classloader-findloadedclass-method-with-example.aspx

Java ClassLoader findLoadedClass()方法与示例相关推荐

  1. Java IOUtils.copy方法代码示例(亲测)

    本文整理汇总了Java中org.apache.commons.io.IOUtils.copy方法的典型用法代码示例.如果您正苦于以下问题:Java IOUtils.copy方法的具体用法?Java I ...

  2. java getresources方法_Java ClassLoader getResources()方法与示例

    ClassLoader类getResources()方法getResources()方法在java.lang包中可用. getResources()方法用于标识具有给定资源名称的所有资源. getRe ...

  3. java user directory,Java ProcessBuilder directory()方法与示例

    语法:public File directory (); public ProcessBuilder directory (File dir); ProcessBuilder类directory()方 ...

  4. Java序列化魔术方法及其示例使用

    在上一篇文章中, 您需要了解有关Java序列化的所有知识 ,我们讨论了如何通过实现Java序列化来启用类的可序列化性. Serializable接口. 如果我们的类未实现Serializable接口, ...

  5. catalog java,Java Connection getCatalog()方法与示例

    通常,目录是一个目录,其中包含有关数据集,文件或数据库的信息.而数据库目录中包含所有数据库,基本表,视图(虚拟表),同义词,值范围,索引,用户和用户组的列表. Connection接口的getCata ...

  6. filepermission java,Java FilePermission getActions()方法与示例

    FilePermission类getActions()方法getActions()方法在java.io包中可用. getActions()方法用于检查此FilePermission和给定对象在路径名和 ...

  7. java方法参数Bundle,Java ResourceBundle keySet()方法及示例

    ResourceBundle类keySet()方法keySet()方法在java.util包中可用. keySet()方法用于从此ResourceBundle及其超级捆绑包中获取所有现有键,以在Set ...

  8. java exec waitfor,Java Process waitFor()方法与示例

    流程类waitFor()方法在java.lang包中提供了waitFor()方法. waitFor()方法用于使当前正在运行的线程在需要时等待,直到由该Process对象表示的进程完成其终止为止. 当 ...

  9. java arraylist.add(),Java ArrayList add()方法与示例

    ArrayList类add()方法 语法:public boolean add(T ele); public void add(int indices, T ele);add()方法在java.uti ...

最新文章

  1. java 单字节_java文件读取。(单字节读取和按行读取读取)
  2. iphone打字怎么换行_库克扎心!12年iPhone老用户换机小米10 Pro,每天玩机七八小时...
  3. 局域网屏幕共享_ShareMouse for Mac(鼠标键盘共享)
  4. 从分布式到云端服务:Google Spanner 成长之路
  5. 让动画每次重复前都有延迟
  6. 1、play编程基础
  7. python中代码段的标志是什么车_请问这段Python代码是什么意思?
  8. java 方法 示例_Java语言环境getDisplayCountry()方法与示例
  9. WORD如何生成两个目录?
  10. 左对齐杨辉三角python_python实现杨辉三角思路
  11. 一本通【例4-10】最优布线问题
  12. linux 7升级win10双系统,安装 Windows 10 + Centos 7 双系统共存
  13. 【渝粤教育】国家开放大学2018年春季 0032-22T农业经济学 参考试题
  14. Vue:错误Component template should contain exactly one root element解决
  15. 大腿神经网络解剖图片,大腿神经网络解剖图谱
  16. 汽车电子EMC:ISO7637-2
  17. kuwo.php采集,PHP获取酷我音乐MP3外链
  18. Nowcoder专项练习:Linux(二)
  19. 关于RHCE考证的那些事
  20. linux poodle漏洞,SSL POODLE[贵宾犬]漏洞的解决办法

热门文章

  1. 服务器物理部署拓扑图,【网络】叶脊(Spine-Leaf)网络拓扑下全三层网络设计与实践(五)-物理服务器路由方案及配置...
  2. jenkins修改pom文件_jenkins使用小技巧:pom.xml文件里的版本随着每次发布变化怎么办?...
  3. 怎么隐藏滚动条又能滚动
  4. jQuery中国各个省份地图分部代码
  5. ValueError: too many values to unpack
  6. HDU 2841 Visible Trees(容斥)题解
  7. 面向对象的数据存储方式
  8. ZooKeeper的原理(转)
  9. xamarin UWP中MessageDialog与ContentDialog的区别
  10. python 编码问题之终极解决