fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.reflect.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone<T>
  9. {
  10. List<T> getList() { return new ArrayList<>(); }
  11.  
  12. public static void main (String[] args) throws java.lang.Exception
  13. {
  14. TypeVariable onClass = Ideone.class.getTypeParameters()[0];
  15. System.out.println(onClass);
  16.  
  17. TypeVariable onMethod = Ideone.class.getDeclaredMethod("getList").getReturnType().getTypeParameters()[0];
  18. System.out.println(onMethod);
  19.  
  20. System.out.println(onClass == onMethod);
  21. }
  22. }
Success #stdin #stdout 0.05s 711168KB
stdin
Standard input is empty
stdout
T
E
false