Getting the returntype of a method through reflection

Get a Method instance from the Class and invoke the method getReturnType.

Main.java:

import java.lang.reflect.*;
import java.util.*;
 
public class Main {
   public static final void main(String[] args) {
      try {
         Class c = Class.forName(args[0]);
         Method m[] = c.getDeclaredMethods();
         for (int i=0; i<m.length; i++) {
            if (m[i].getName().equals(args[1])) {
               Class returnType = m[i].getReturnType();
               System.out.println(returnType + " " + args[0] + "::" + args[1]);
            }
         }
      }
      catch(ClassNotFoundException e) {
         System.err.println(e);
      }
   }
}

output for java Main Main main

void Main::main

output for java Main java.util.Vector size

int java.util.Vector::size