I have this interface:
interface MyInt<T> {
public void foo(T t);
}
And these classes:
class MyString implements MyInt<String> {
@Override
public void foo(String t) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
}
class MyDouble implements MyInt<Double> {
@Override
public void foo(Double t) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
}
Now I want to test if a class not only implements MyInt
(i can do that), but if that class implements MyInt<String>
, my code so far:
Class<MyInt> c = MyInt.class;
Class c0 = MyString.class;
Class c1 = MyDouble.class;
System.out.println(c.isAssignableFrom(c0)); //true
System.out.println(c.isAssignableFrom(c1)); //true
Every try for adding the String "sublass" (dont even know correct name for T) result in compilation error. Any way to do this?