Import Java. Lang. annotation. annotation; Import Java. Lang. Reflect. constructor; Import Java. Lang. Reflect. method; // Use two annotations to modify the class @ Suppresswarnings (value = "unchecked" ) @ Deprecated Public Class Classtest { // Define a private constructor for this class Private Classtest (){} // Define a constructor with Parameters Public Classtest (string name) {system. Out. println ( "Execute the constructor with Parameters" );} // Define a info method without Parameters Public Void Info (string Str) {system. Out. println ( "Execute the info method with Parameters" + ". In fact, the STR parameter value is:" + Str );} // Define an internal class for testing Class Inner {} Public Static Void Main (string [] ARGs) Throws Exception { // BelowCodeYou can obtain the class corresponding to classtest. Class <classtest> clazz = classtest. Class ; // Obtains all constructors of the class corresponding to this class object. Constructor [] ctors =Clazz. getdeclaredconstructors (); system. Out. println ( "All constructors of classtest are as follows :" ); For (Constructor C: ctors) {system. Out. println (c );} // Obtains all the public methods of the Class Object. Constructor [] publicctors = Clazz. getconstructors (); system. Out. println ( "All public constructors of classtest are as follows :" ); For (Constructor C: publicctors) {system. Out. println (c );} // Obtains the specified method of the class corresponding to the class object. Method [] MTDS = Clazz. getmethods (); system. Out. println ( "All public methods of classtest are as follows :" ); For (Method MD: MTDs) {system. Out. println (MD );} // Obtains the specified method of the class corresponding to the class object. System. Out. println ("the info method with a string parameter in classtest is:" + clazz. getmethod ("info", String. Class )); // Obtains all comments on the corresponding class of the Class Object. Annotation [] Anns = Clazz. getannotations (); system. Out. println ( "All annotattion of classtest is as follows :" ); For (Annotation an: ANNs) {system. Out. println (an);} system. Out. println ( "The @ suppresswarnings comment on this class element is:" + Clazz. getannotation (suppresswarnings. Class )); // Obtains all internal classes of the Class Object. Class <?> [] Inners =Clazz. getdeclaredclasses (); system. Out. println ( "All internal classes of classtest are as follows :" ); For (Class C: inners) {system. Out. println (c );} // Use the class. forname method to load the inner class of classtest Class inclazz = Class. forname ("classtest $ inner" ); // Use getdeclaringclass () to protect the external class of this class System. Out. println ("the external class of the inclazz class is:" + Inclazz. getdeclaredclasses (); system. Out. println ( "Classtest package:" +Clazz. getpackage (); system. Out. println ( "The parent class of classtest is:" + Clazz. getsuperclass ());}}