2012-11-16 7 views

Odpowiedz

83

Aby wywołać metodę z prymitywnych typów jako parametrów przy użyciu odbicia:

Można użyć int.class

this.getClass().getMethod("Test",int.class).invoke(this, 10); 

lub Integer.TYPE

this.getClass().getMethod("Test",Integer.TYPE).invoke(this, 10); 

dotyczy to również innych typów pierwotnych:

9

Dziwne, ale prawdziwe:

this.getClass().getMethod("Test",int.class).invoke(this, 10); 
Powiązane problemy