What is the difference between using ordinary new and using the reflection class method to instantiate a class?
小公2018-09-05 11:03:00
1. When using reflection, you must ensure that this class has been loaded and connected. When using new, this class may not be loaded or may already be loaded.
2. The new keyword can call any public constructor, while reflection can only call no-argument constructors.
3. The new keyword is strongly typed and relatively efficient. Reflection is weakly typed and inefficient.
4. Reflection provides a more flexible way to create objects and obtain object information. For example, the use of AOP in Spring and the use of dynamic proxies are all based on reflection. Decoupling