请看下面的代码:

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

}

}

相关文章:

  • 2022-12-23
  • 2022-01-02
  • 2022-12-23
  • 2021-12-27
  • 2021-12-27
  • 2021-08-06
猜你喜欢
  • 2021-11-10
  • 2021-10-15
  • 2021-08-06
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案