当前位置:网站首页>Understanding of class
Understanding of class
2022-07-03 07:21:00 【four thousand three hundred and forty-three】

package JavaReflcet;
import org.junit.Test;
public class ClassTest {
/*
obtain Class The way of example
*/
@Test
public void test1() throws ClassNotFoundException {
// Mode one : Call the properties of the runtime class : .class
Class clazz = person.class;
System.out.println(clazz);
// The way 2: Through the object of the runtime class
person p1 = new person();
Class<? extends person> clazz2 = p1.getClass();
System.out.println(clazz2);
// The way 3: call Class Static method of :forName(String classPath)
Class clazz3 =Class.forName("JavaReflcet.person");
System.out.println(clazz3);
// The way 4: Using loaders for classes :ClassLoader
ClassLoader classLoader = ReflactionTest.class.getClassLoader();
Class<?> clazz4 = classLoader.loadClass("JavaReflcet.person");
System.out.println(clazz4);
}
}
person The runtime class of can be regarded as a singleton :
clazz == clazz2 //true
clazz2== clazz3 //true
边栏推荐
- PdfWriter. GetInstance throws system Nullreferenceexception [en] pdfwriter GetInstance throws System. NullRef
- Crontab scheduled task
- TreeMap
- 【无标题】
- Arduino Serial系列函数 有关print read 的总结
- SecureCRT password to cancel session recording
- Summary of Arduino serial functions related to print read
- Distributed ID
- Arduino 软串口通信 的几点体会
- 691. 立方体IV
猜你喜欢

Hash table, generic

Take you through the whole process and comprehensively understand the software accidents that belong to testing

Selenium key knowledge explanation
![[Fiddler actual operation] how to use Fiddler to capture packets on Apple Mobile Phones](/img/d0/850e095a43610366d6144b2471f3f7.jpg)
[Fiddler actual operation] how to use Fiddler to capture packets on Apple Mobile Phones

Interview questions about producers and consumers (important)

最全SQL与NoSQL优缺点对比

专题 | 同步 异步

Setting up the development environment of dataworks custom function

IP home online query platform

Inno setup production and installation package
随机推荐
CentOS php7.3 installing redis extensions
Jmeter+influxdb+grafana of performance tools to create visual real-time monitoring of pressure measurement -- problem record
Advanced APL (realize group chat room)
[HCAI] learning summary OSI model
Warehouse database fields_ Summary of SQL problems in kingbase8 migration of Jincang database
Homology policy / cross domain and cross domain solutions /web security attacks CSRF and XSS
[set theory] partition (partition | partition example | partition and equivalence relationship)
【最详细】最新最全Redis面试大全(50道)
深度学习参数初始化(一)Xavier初始化 含代码
File links cannot be opened or downloaded in Google browser
OSI knowledge sorting
Pits encountered in the use of El checkbox group
Summary of Arduino serial functions related to print read
Jeecg request URL signature
Inno Setup 制作安装包
The underlying mechanism of advertising on websites
Specified interval inversion in the linked list
PHP install the spool extension
Sorting, dichotomy
MySQL transaction rollback, error points record