上课 [英] loading the class
本文介绍了上课的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
我毫不怀疑.如果我错了,请纠正我.
(1)我已经阅读了很多论坛,他们说Class.forname("X")会将类X加载到内存中或注册您的类.在javadocs中,他们说对forName("X")的调用会导致在这种情况下,类的初始化与将类加载到内存中相同吗?
(2)调用类意味着创建类的实例(对象).这与该类的实例不同.这样,您就可以通过反射来获取有关特定类的信息,从而可以动态地访问类的字段或方法.
Hi all,
I have few doubts. Please correct me if I am wrong.
(1) " I''ve read so many forums and they say Class.forname("X") will load the class X into memory or register your class. In javadocs, they say a call to forName("X") causes the class named X to be initialized. " in this context, initialization of class is same as loading the class into memory ?
(2) invoking the class means creating the instance (object) of the class.
解决方案
This call returns the runtime Class object; this is not the same as an instance of the class. This allows you to get information about a particular class through reflection, which in turn allows you to access fields or methods of a class dynamically.
这篇关于上课的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文