mardi 26 juillet 2016

Array of generic holders

If I have a map of Entry .. objects , and I have an array in a class

private Entry<K,V> array;

Can I say

array = new Entry[someInt];

which I've done, or do I need a typecast like my instructor says is necessary such as

array = (Entry<K,V> E[]) new Entry[someInt];

Note that the first one did work when I ran my JUnits.

Aucun commentaire:

Enregistrer un commentaire