2012-11-16 50 views

回答

83

要撥打與原始類型作爲參數的方法,使用反射:

你可以使用 int.class

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

Integer.TYPE

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

同樣適用於其他原始類型

9

奇怪但卻真實:

this.getClass().getMethod("Test",int.class).invoke(this, 10); 
相關問題