How do I reflectively invoke a method with null as argument?

后端 未结 4 1032
臣服心动
臣服心动 2021-02-02 07:32

I am trying to invoke this method in Java reflectively:

public void setFoo(ArrayList foo) { this.foo = foo; }

The problem is that

4条回答
  •  眼角桃花
    2021-02-02 08:08

    For me, this DOES NOT work:

    m.invoke ( c.newInstance() , new Object[] { null } );

    BUT this works:

    m.invoke ( c.newInstance() , new Object[] { } );

提交回复
热议问题