当前位置:网站首页>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
边栏推荐
猜你喜欢

4279. 笛卡尔树

Le Seigneur des anneaux: l'anneau du pouvoir

Mise en place d'un environnement de développement de fonctions personnalisées

4279. Cartesian tree

Use the jvisualvm tool ----- tocmat to start JMX monitoring

Inno setup production and installation package

Jmeter+influxdb+grafana of performance tools to create visual real-time monitoring of pressure measurement -- problem record

Distributed transactions

Topic | synchronous asynchronous

高并发内存池
随机推荐
gstreamer ffmpeg avdec解码数据流向分析
Some experiences of Arduino soft serial port communication
POI excel percentage
The underlying mechanism of advertising on websites
Thoughts on project development
Arduino Serial系列函数 有关print read 的总结
20220319
Advanced API (serialization & deserialization)
Le Seigneur des anneaux: l'anneau du pouvoir
docker建立mysql:5.7版本指定路径挂载不上。
691. 立方体IV
dataworks自定義函數開發環境搭建
High concurrency memory pool
How to specify the execution order for multiple global exception handling classes
IP home online query platform
[most detailed] latest and complete redis interview book (50)
[set theory] partition (partition | partition example | partition and equivalence relationship)
"Moss ma not found" solution
万卷书 - 价值投资者指南 [The Education of a Value Investor]
Take you through the whole process and comprehensively understand the software accidents that belong to testing