Class: getDeclaredMethod(String name, Class>... parameterTypes)
import java.io.PrintStream;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
public class Main {
public static void main(String[] args) throws NoSuchMethodException,
IllegalAccessException, InvocationTargetException {
Method m = PrintStream.class.getDeclaredMethod("println", String.class);
m.invoke(System.out, "Hello, World!");
}
}
Related examples in the same category