Understand the Java reflection mechanism

1. The reflection mechanism of Java means that in the running state of the program, objects of any class can be constructed, the class to which any object belongs, the member variables and methods of any class can be known, and any class can be called. Object properties and methods. This function of dynamically obtaining program information and dynamically calling objects is called the reflection mechanism of the Java language. Reflection is considered the key to dynamic languages.

2. Reflection mechanism: The so-called reflection mechanism is that the Java language has a self-observation ability at runtime. Through this ability, you can thoroughly understand your own situation and prepare for the next step.

3. In the Java runtime environment, for any class, you can know which properties and methods this class has. For any object, any method of it can be called. This function of dynamically obtaining class information and dynamically calling object methods comes from the reflection mechanism of the Java language.
The normal method is to create an object through a class, and the reflection method is to find information about a class through an object.

Guess you like

Origin blog.csdn.net/fl6881688/article/details/116427576