任何人都可以帮我找到JAVA中方法的返回类型.我试过这个.但不幸的是它不起作用.请指导我.
 Method testMethod = master.getClass().getMethod("getCnt");
  if(!"int".equals(testMethod.getReturnType()))
   {
      System.out.println("not int ::" + testMethod.getReturnType());
   }
输出:
不是int :: int
Gab*_*tti 13
该方法getReturnType()返回Class
你可以试试:
if (testMethod.getReturnType().equals(Integer.TYPE)){ 
      .....;  
}
if(!int.class == testMethod.getReturnType())
{
  System.out.println("not int ::"+testMethod.getReturnType());
}