I do not know what I'm doing wrong but when I try initialize public final Comparator<K> cmp to a value, I get an error.
public class FastGetListMM<K,V> extends AbstractListMM<K,V> {
// Comparator used to sort elements; may be null if elements are Comparable
public final Comparator<K> cmp;
private List<K> keys;;
private List<V> values;
// Assume elements must be comparable
public FastGetListMM(ArrayList<K> keys, ArrayList<V> values)
{
super(keys, values);
//this.cmp = new Comparator<K>(); <<----error
}
// Use the given comparator to sort the keys
public FastGetListMM(Comparator<K> cmp)
{
super(cmp); <<-----error
//this.cmp = cmp; <<----error
}
AbstractListMMclass has an comparator?Comparatoris interface, you cannot instantiate it bynewdirectly. Or you need to instantiate anonymous class for it.Cannot instantiate the type Comparator<K>