fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6. import java.lang.reflect.*;
  7.  
  8. /* Name of the class has to be "Main" only if the class is public. */
  9. class Ideone
  10. {
  11. public static void main (String[] args) throws java.lang.Exception
  12. {
  13. // your code goes here
  14. // ArrayList<Integer> list = new ArrayList<Integer>();
  15. // System.out.println(list.getClass());
  16. // System.out.println(list.getClass().getGenericSuperclass());
  17. // System.out.println(((ParameterizedType) list.getClass().getGenericSuperclass()).getActualTypeArguments()[0].getTypeName());
  18.  
  19. System.out.println(new C<String>("hello world!").RESOURCE_TYPE);
  20. }
  21.  
  22. }
  23.  
  24. class B {}
  25. final class C<T> extends B {
  26. public final Type RESOURCE_TYPE;
  27. public final T value;
  28.  
  29. C(T value) {
  30. this.value = value;
  31. System.out.println(this.value);
  32. this.RESOURCE_TYPE =
  33. (/*(ParameterizedType)*/ getClass().getGenericSuperclass());//.getActualTypeArguments()[0];
  34. System.out.println(this.RESOURCE_TYPE);
  35. }
  36. }
Success #stdin #stdout 0.06s 2184192KB
stdin
Standard input is empty
stdout
hello world!
class B
class B