如何通过反射调用对象的方法?
import java.lang.reflect.Method;class MethodInvokeTest { public static void main(String[] args) throws Exception { String str = "hello"; Method m = str.getClass().getMethod("toUpperCase"); System.out.println(m.invoke(str)); // HELLO }}
今日事今日毕

浙公网安备 33010602011771号