So, I have this general HashTable class that I am developing, and I want to use it in general for any number of input types, and I want to also initialize the internal memory array as a LinkedList array (for collision purposes), where each LinkedList is predefined (for type safety) to be a generic type from the HashTable class. How can i do this? The following code best explains my intentions, but of course it does not compile.
public class HashTable<K, V> { private LinkedList<V>[] m_storage; public HashTable(int initialSize) { m_storage = new LinkedList<V>[initialSize]; } }
java generics hash
Ben lakey
source share