How to instantiate an array of Map<Integer, Double> ?
I'm trying to convert legacy code to use generics.
Old data structure:
Hashtable positions[] = new Hashtable[n];
New (unsuccessful...) attempt:
Map<String, Double> positions[] = new HashMap<String, Double>()[n];
Can't get this to compile, no matter what permutation I try of <> and ().
Can someone please explain how to do it?
Thanks,
[403 byte] By [
zebulaha] at [2007-10-2 10:57:19]

> I'm trying to convert legacy code to use generics.Can't try right now, but I'd guessMap<String, Double>[] positions = new HashMap<String, Double>[n];
> > I'm trying to convert legacy code to use generics.
>
> Can't try right now, but I'd guess
>
> Map<String, Double>[] positions = new
> HashMap<String, Double>[n];
Unfortunately this will not work. There are limitations when declaring generic arrays that mean you have to do something like -
Map<String, Double>[] positions = (Map<String, Double>[]) new HashMap[10];
Not very nice but ...