Reputation: 113
I am working through a text book which has the following code:
Entry<K,V>[] tempTable = (Entry<K,V>[]) new Entry[size];
When I compile with -Xlint
, it says the Entry
on the right is missing the type arguments. However, I cannot add the type arguments, as this would lead to generic array creation. I guess my question is two-part:
Upvotes: 1
Views: 95
Reputation: 2009
Your best bet would be to use the Collection
interface, List
to
1- make it more elegant, and
2- get rid of the warnings
List<Entry<K, V>> tempTable = new ArrayList<>();
tempTable.add(new Entry<Integer, Double>()); // or whatever object.
I hope this helps.
Upvotes: 1