java reflection principle use

1. First with Java reflection mechanism to achieve a purpose: We all know that obtained by the specified method or property of an object, etc., based on this principle we do a

Common feature that lets client can identify incoming objects and to call a method in this object you want. This achieves the effect of a law of a multi-purpose

. 1  // methodName corresponds to a method of identification obtained meth Method 
2 Method, meth obj1.getClass = () getMethod (methodName, the Map.. Class );
 . 3  // OBJ1 corresponds container storage method = a public example, obj2 corresponding to the request parameters 
. 4  meth.invoke (obj1, obj2);
 . 5  
. 6 so that we can change and different methods obj1 methodName different objects in the

 

Guess you like

Origin www.cnblogs.com/panca/p/10931695.html