Spring IOC implementation principle basic example:
package com.xing; import java.lang.reflect.Field; import java.lang.reflect.Method; import javax.crypto.Cipher; import com.huawei.ihap.common.encryption.SecurityException; import com.huawei.ihap.common.encryption.SecurityUtils; public class Test4 { public static void main(String[] args) { Class<?> cl=null; try { cl = Class.forName("com.xing.Animal");//Get the class } catch (ClassNotFoundException e) { e.printStackTrace (); } System.out.println("c1 class == " + cl.getSimpleName()); System.out.println("c1 class == " + cl.getName()); System.out.println("c1 class == " + cl.getSimpleName()); System.out.println("c1 class == " + cl.getClass()); Method[] c1methods = cl.getMethods(); //Get all methods for(int i=0;i<c1methods.length;i++){ System.out.println("c1methods == " + c1methods[i].getName()); System.out.println("c1methods == " + c1methods[i].getReturnType()); } Field[] field = cl.getDeclaredFields();//Get the field (parameter) for(int i=0;i<field.length;i++){ System.out.println("field == " + field[i].getName()); System.out.println("field == " + field[i].getType()); } try { Animal animal = (Animal)cl.newInstance(); //Create a new object } catch (InstantiationException e) { // TODO Auto-generated catch block e.printStackTrace (); } catch (IllegalAccessException e) { // TODO Auto-generated catch block e.printStackTrace (); } } }