我试图通过Java反射调用一个方法,它没有任何参数:
Method getSelectedCriteriaMethod = multipleSorting.getClass().getDeclaredMethod("getSelectedCriteria", null); EstimateSortField selectedCriteria = (EstimateSortField)getSelectedCriteriaMethod.invoke(multipleSorting, null);
这是有效的,但我收到编译器警告:
warning: non-varargs call of varargs method with inexact argument type for last parameter; cast to java.lang.Class> for a varargs call non-varargs call of varargs method with inexact argument type for last parameter; cast to java.lang.Object for a varargs call
调用没有任何参数的方法的正确方法是什么?
你可以简单地说
selectedCriteria.invoke(multipleSorting);