The Java language provides a reflection mechanism, which also provides a way to dynamically create Java instance objects. The difference between a lot of people who create objects for new and reflection is that dynamic creation is not very understandable, because after all, even creating objects with the New keyword is actually created "dynamically" because they are created when the virtual runtime is running, so how should this dynamic creation be understood? In fact, the so-called dynamics, can be understood as in some cases, we can not modify the Java code to implement at any time "dynamic" additions and deletions of new Java objects. Now throw away the reflection mechanism, if we need new Java objects in a project, what should we do? It is, of course, obtained through new, and then the code is recompiled. If there is a reflection mechanism, we can not be so troublesome, directly on demand through the corresponding type fully qualified class name dynamically create objects and use, then the required class name how come? You can dynamically create the object instances that we need by writing the class name in the configuration file and then directly reading the configuration file. In fact, the strong spring is doing this. By the way, the spring container uses the reflection mechanism to provide us with the dynamic instance object, which is actually taking advantage of encapsulation, encapsulating the concrete implementation of the underlying reflection creation object, and we just need to pass in a parameter of the full class name to get an instance of the corresponding class.
Understanding of the Java reflection mechanism