How do I add a generic in Java to an implements interface?

Viewed 32

I am writing an implementation of the Java List interface. When implementing the List method I run into the issue, that all my method are of "Object" instead of "T", which is what I actually want.

  • Is there any possible way to create a class that I could create something like the code below?
  • Why does the generic after "implements List" produce an error?
public class SortableList<T extends Comparable<T>> implements List<T>

I have also looked at this question, but I haven't found the answer I was looking for. Java generics interface implementation

EDIT: The solution to the problem is, deleting the old override methods and re-implenting the new override methods.

0 Answers
Related