当前位置:网站首页>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
边栏推荐
- 4EVERLAND:IPFS 上的 Web3 开发者中心,部署了超过 30,000 个 Dapp!
- Flask Foundation
- How can I split a string at the first occurrence of “-” (minus sign) into two $vars with PHP?
- Visit Google homepage to display this page, which cannot be displayed
- Summary of Arduino serial functions related to print read
- Jmeter+influxdb+grafana of performance tools to create visual real-time monitoring of pressure measurement -- problem record
- Laravel frame step pit (I)
- Advanced API (serialization & deserialization)
- Advanced APL (realize group chat room)
- Advanced API (batch image Download & socket dialog)
猜你喜欢

Map interface and method

带你全流程,全方位的了解属于测试的软件事故

Le Seigneur des anneaux: l'anneau du pouvoir

Summary of Arduino serial functions related to print read

C代码生产YUV420 planar格式文件

【已解决】Unknown error 1146

Win 10 find the port and close the port

Basic components and intermediate components

最全SQL与NoSQL优缺点对比
![PdfWriter. GetInstance throws system Nullreferenceexception [en] pdfwriter GetInstance throws System. NullRef](/img/65/1f28071fc15e76abb37f1b128e1d90.jpg)
PdfWriter. GetInstance throws system Nullreferenceexception [en] pdfwriter GetInstance throws System. NullRef
随机推荐
Map interface and method
[set theory] partition (partition | partition example | partition and equivalence relationship)
[Fiddler actual operation] how to use Fiddler to capture packets on Apple Mobile Phones
CentOS switches and installs mysql5.7 and mysql8.0
Discussion on some problems of array
Recursion, Fibonacci sequence
Basic knowledge about SQL database
Inno setup production and installation package
Mise en place d'un environnement de développement de fonctions personnalisées
Wireshark software usage
Gridome + strapi + vercel + PM2 deployment case of [static site (3)]
Sorting, dichotomy
Book recommendation~
Setting up the development environment of dataworks custom function
Advanced API (UDP connection & map set & collection set)
gstreamer ffmpeg avdec解码数据流向分析
Jeecg request URL signature
TypeScript let与var的区别
[day15] introduce the features, advantages and disadvantages of promise, and how to implement it internally. Implement promise by hand
I. D3.js hello world