while writing this
this.BucketArray = (GenericLinkedList[]) new GenericLinkedList[size];
we get error :-
Type safety: Unchecked cast from GenericLinkedList[] to
GenericLinkedList<HashMap<K,V>.HTPair>[]
HOW TO RESOLVE THIS
while writing this
this.BucketArray = (GenericLinkedList[]) new GenericLinkedList[size];
we get error :-
Type safety: Unchecked cast from GenericLinkedList[] to
GenericLinkedList<HashMap<K,V>.HTPair>[]
HOW TO RESOLVE THIS
see line no:- 16 and 35
@RULEREMPIRES,
Your code is correct.
The problem is the cast isn’t checked. So, you have to check it yourself. You can’t just check a parameterized type with instanceof, because the parameterized type information is unavailable at runtime, having been erased at compile time.
But, you can perform a check on each and every item in the hash, with instanceof, and in doing so, you can construct a new hash that is type-safe. And you won’t provoke any warnings.
Or you can just add @SuppressWarnings("unchecked")
on top of the hashmap constructor