Much to the disgust of Josh (and the surprise of myself) I am actually somewhat enjoying my recent foray into the murky waters of Java 5 Generics. Iâ€™ve spent the last few hours writing a specialised Map that can take multiple values for the same key (yes, I realise that such functionality would technically no longer make it a Map, thus, I called it a Bag :P). Everything went quite smoothly save for one little gotcha: Arrays. I wanted to return an array form a particular method with something like the following:
[The requested file http://tim.littlebluefrog.com/code/26-oct-2005/PropertyBag.java could not be found]
The only problem is that you canâ€™t create generic arrays. Fat lot of good that did me. There is a quite a good explanation of why here for those really interested. The end result is that I implemented these methods using Lists rather than arrays (like I really should have been doing from the start). Itâ€™s no big deal, but I can see that generic arrays would be a nice thing to have (curse you type erasure, CURSE YOU!).