Keeping generic types when implementing in class

class, generics, interface, java

Solution

Specify the type like `SortAnalysis<E>` in

public class InsertionSort<E extends Comparable<? super E>> 
        implements SortAnalysis<E> {

when you omit it you have a raw-type and not a generic version.

Problem

I've done a lot of searching through generic type questions and just haven't found anything that has helped me figure out what I am doing wrong here. I have an interface as follows: ``` public interface SortAnalysis<E extends Comparable<? super E>> { public long analyzeSort(ArrayList<E> list); } ``` Now, the next step is making a class that implements this interface. This particular class is going to use an insertion sort and I need to keep the ArrayList type 'E' generic, so I tried all sorts of things and ended up with the following: ``` public class InsertionSort<E extends Comparable<? super E>> implements SortAnalysis { @Override public long analyzeSort(ArrayList list) { // TODO Auto-generated method stub return 0; } ``` My problem is that when I try to do this for the parameter ``` ArrayList<E> list ``` the compiler gripes at me about implementing a supertype method. I would really appreciate any direction of help. Thanks! **I can't mark this as answered yet, but it is. I think my problem had been that when I had ``` SortAnalysis<E> ``` I did not have the generic typing listed after the class name.**

Original source