Generic types in Java are only working at the compilation level, the generated byte code does not contain any generic types.
Type erasure replaces all type parameters in generic types with their bounds or Object if the type parameters are unbounded. Hence the class declaration class Manipulators<T> may be considered equivalent to class Manipulators<Object>. Since objects of type of Object don't have an f() method, the code will fail to compile.
In order to make it compile - we should set the boundaries: class Manipulators<T extends HasF>
Войдите чтобы поставить Нравится
Войдите чтобы прокомментировать