Java reflection

Java reflection is in the running state, for any class, you can know all the properties and methods of this class; for any object, you can call any of its methods and properties; and you can change its properties.

We know that the reflection mechanism allows the program to obtain the internal information of any class with a known name at runtime, including its modifiers (modifiers), fields (attributes), methods (methods), etc., and can change the contents of fields or Call methods. Then we can write code more flexibly, the code can be assembled at runtime, there is no need to link the source code between the components, reducing the coupling of the code; there is also the realization of dynamic agents, etc.; but we need to pay attention to the improper use of reflection Will cause high resource consumption!

Guess you like

Origin blog.csdn.net/qq_36073688/article/details/112547591