ulvis.paste.net

Paste Search Dynamic
Recent pastes
SuperTest
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Main
  9. {
  10.         public static void main (string[] args) throws java.lang.exception
  11.         {
  12.                 TestClass tc = new TestClass();
  13.                 system.out.println(tc.getTypeE() == Test1.class);
  14.                 system.out.println(tc.getTypeF() == Test2.class);
  15.         }
  16. }
  17.  
  18. class SuperTest {
  19. }
  20. class Test1 extends SuperTest{
  21. }
  22. class Test2 extends SuperTest{
  23. }
  24. class SuperTestClass <E extends SuperTest, F extends SuperTest> {
  25.     @SuppressWarnings("unchecked")
  26.     public Class<E> getTypeE(E... e) {
  27.                 return (Class<E>) e.getClass().getComponentType();
  28.     }
  29.     @SuppressWarnings("unchecked")
  30.     public Class<F> getTypeF(F... f) {
  31.                 return (Class<F>) f.getClass().getComponentType();
  32.     }
  33. }
  34. class TestClass extends SuperTestClass<Test1, Test2> {
  35. }
Parsed in 0.014 seconds