I am trying to implement my own version of HashMap. FDor storing the items I would like to use an ArrayList of LinkedLists and for that I am taking "program to interface" approach. So the items type is List <List<MyEntry<k,v>>>
but
I wanna instantiate it by ArrayList< LinkedList< MyEntry< k,v>>>()
what is wrong with my code that I get compilation error
Type mismatch: cannot convert from ArrayList< LinkedList< MyHashMap1< k,v>.MyEntry<k,v>>>
to List<List<MyHashMap1<k,v>.MyEntry<k,v>>>
My question is
If I change the type to List< LinkedList< MyEntry< k, v>>>
It works but List< LinkedList< MyEntry< k, v>>>
is not %100 interface, LInkedList is not an interface
package maps;
import java.util.ArrayList;
import java.util.List;
import java.util.LinkedList;
public class MyHashMap1<k,v> {
//Type mismatch: cannot convert from ArrayList<LinkedList<MyHashMap1<k,v>.MyEntry<k,v>>> to List<List<MyHashMap1<k,v>.MyEntry<k,v>>>
List <List<MyEntry<k,v>>> items = new ArrayList<LinkedList<MyEntry<k,v>>>();
public class MyEntry<a,b>{
a key;
b value;
public MyEntry(a key,b value){
this.key = key;
this.value = value;
}
}
}