反射静态方法

package com.intelink.wechat_lyl.test;
import java.lang.reflect.Method;

public class Test {

    public static void main(String[] args){
        try {
            Class clz= Class.forName("com.intelink.wechat_lyl.test.TestMethod");
            Method m = clz.getDeclaredMethod("test1");
            m.invoke(null);
        }catch (Exception e){
            e.printStackTrace();
        }
    }
}
package com.intelink.wechat_lyl.test;

public class TestMethod {

    static void test1(){
        System.out.println("test");
    }
}


你可能感兴趣的:(Android,Studio)