Java reflection mechanism, in the running state of Java, for any class, can know all his properties and methods, for any object, can call his methods and properties; This dynamic access to information, the function of dynamic call method is called the Java Reflection mechanism.
We can load, detect, and use classes that are completely unknown during compilation at runtime. In other words, a Java program can load a runtime to know the name of a class, learn its full construct (but not including the methods definition), and generate its object entities, or set values on its fields, or evoke its methods.
Java reflection using frequent methods
Class.forName ();//Load Java class
Clase method: Newinstance (), used to generate an instance of the class (no parameter constructs)
GetConstructor (), constructor with parameters, get method
Methods of constructor:
Newinstance (ARG), generating object entities
GetMethod (), Get method by method name and parameter type
Method: Invoke () execution method
GetField (), by property name, gets the attribute field
Method of field: Set (), Get ()
Java Reflection mechanism