且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

当构造函数将字符串数组作为参数时,使用反射创建对象实例

更新时间:2023-11-15 12:04:52

newInstance 接受一个 Object... 参数,所以当你给它一个 String[] 时它会通过它作为 Object[].

newInstance takes an Object... argument so when you give it a String[] it passes it as the Object[].

你想要的是以下内容,它告诉它你只传递一个参数,而不是数组的内容作为参数.

What you want is the following which tells it you are passing just one argument, not the contents of the array as arguments.

.newInstance((Object) job1.arg_arr())