The first way: the object obtained by the class itself
Class classname = this .getClass ();
the second way: by acquiring parent class object instance of a subclass of
Sub sub = new Sub (); Class clazz = sub.getClass () ;
class parentClass clazz.getSuperclass = ();
third way: by class name (class full path) is added .class get the object class forClass = ** ** ClassName.class; (classes in the package. .class plus path)
the fourth embodiment: the object acquired by the string class name class forName = Class.forName ( "** ** className.."); such as: class = forName the Class.forName ( " com.itheima.Sub "); in this way it is used in the jdbc.
Obtaining a class object class what way?
Guess you like
Origin blog.csdn.net/qq_39581763/article/details/104199110
Recommended
Ranking