扫码关注官方订阅号
其实这么写就可以了。
public static void main(String[] args) { A a1 = new A(); Class<?> c = A.class; try { Method m = c.getMethod("print", int.class, int.class); Object o = m.invoke(a1, 10, 20); } catch (Exception e) { e.printStackTrace(); } }
为什么传Integer[]会有警告,因为参数类型是Object...。
Integer[]
Object...
微信扫码关注PHP中文网服务号
QQ扫码加入技术交流群
Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
PHP学习
技术支持
返回顶部
其实这么写就可以了。
为什么传
Integer[]会有警告,因为参数类型是Object...。