Ex: Class A
public Class A
{
public void setName(String name)
{
}
}
A a = new A();
Class c = Class.forName( "A ");
Method method = c.getMethod( "setName ", new Class[]{String.class});
//從Class c中找到名為setName, 帶一個String參數的methid
method.invoke(a, new Object[]{ "name "});
//調用a的該方法, 參數為"name"的String
以上相當於a.setName( "name ");