从类得到方法

import java.lang.reflect.Method;

public class ClassWarning {
    void m() {
        try {
            Class c = ClassWarning.class;
            Method m = c.getMethod("m"); // warning

            // production code should handle this exception more gracefully
        } catch (NoSuchMethodException x) {
            x.printStackTrace();
        }
    }
}

你可能感兴趣的:(从类得到方法)