One. 3 ways to get a class object:
1. Class.forName (""); for example: Class.forName ("java.lang.String");
2. Class.class; for example: String.class; This method requires a class
3. Object. GetClass (); For example: string str = new string (); Str.getclass; This method requires an object
Two. Reflection Generation Object Method:
1. Create the Class object first, and generate the object directly from the Newinstance () method of the Class object. The object generated by this method can only be constructed without parameters;
class<?> CLZ = String.class; Object obj = clz.newinstance ();
2. First create the Class object, in the Get object constructor object, in passing the constructor object's Newinstance () method;
class<?> CLZ = Customer.class;
Constructor con = clz.getdeclaredconstructor (new class[] {String. Class, Int.class});
Object obj = con.newinstance (new object[]{"Hello", "Ten}");
Summary of Java Reflection