1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
|
ClassLoader cl = new Arithmetic().getClass().getClassLoader(); Class clazz3 = cl.loadClass("com.javaee_02.exer1.Arithmetic"); Arithmetic ar3 = (Arithmetic)clazz3.newInstance(); System.out.println(clazz3.getName());
Class clazz2 = Class.forName("com.javaee_02.exer1.Arithmetic"); Arithmetic ar2 = (Arithmetic)clazz2.newInstance();
Arithmetic ar1 = new Arithmetic(); Class clazz1 = ar1.getClass();
Class<Arithmetic> clazz = Arithmetic.class; Arithmetic ar = (Arithmetic)clazz.newInstance();
|
近期评论