The previous version of this code works properly but does not use generics. I want to use generics.
I don't know how to deal with generic arrays like Item<K,V>. When I tried using ArrayList<Item><K,V>> instead of Item<K,V> the warning and the stack trace went away -- and so did the serialization!
Can someone kindly help me fix these problems so it will serialize properly?
Can someone kindly explain why I can say new ArrayList<Item><K,V>> but not new Item<K,V>. Thru google searching I've found such explanations as "K and V don't exist at run time so we cannot define an array of Item<K,V>, instead we can only define an array of Item." Is there basically just an inconsistency between arrays of Item<K,V> and Vectors, Sets and ArrayLists of Item<K,V>? It seems to me they should have been consistent instead of making arrays a special case. Perhaps someone can explain why sun was inconsistent here?
So I tried to apply page 15 and I'm still getting warnings on lines 27 and 28. Why cannot I cast without a warning. The examples on page 15 have an example of storing an element in an array, and examples of how not to extract an element in an array, and no examples of how to properly extract an element from an array!