fork(2) download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.lang.reflect.*;
  6. import java.io.*;
  7.  
  8. /* Name of the class has to be "Main" only if the class is public. */
  9. class Test
  10. {
  11. private static Method doSomethingMethod;
  12. static {
  13. try {
  14. doSomethingMethod =
  15. Test.class.getMethod("doSomething", Integer.TYPE, Integer.TYPE, Integer.TYPE);
  16. } catch (Exception e) {
  17. }
  18. }
  19. public static int doSomething(int a, int b, int c) {
  20. return a + b + c;
  21. }
  22. public static void main (String[] ignore) throws java.lang.Exception
  23. {
  24. Object[] args = new Object[] {1, 2, 3};
  25. Object res = doSomethingMethod.invoke(null, args);
  26. System.out.println(res);
  27. }
  28. }
Success #stdin #stdout 0.04s 4386816KB
stdin
Standard input is empty
stdout
6