After two hours of frustration, thought I'd post.
I'm trying to upgrade my application to
Java 5 (JDK 1.5.0).
Generics frustrate me. Printed out the transition PDF
white paper. Read through it and marked it up. Still
having difficulty.
Simply stated, how does one declare and initialize an
array of three ArrayLists whose generic type (for example)
is
String ? Is the secret in the usage of a wildcard "?" ?
Here's how it was done with 1.4.2 ... simple ...
ArrayList [] array = new ArrayList []
{ new ArrayList(), new ArrayList(), new ArrayList() };
or ArrayList [] array = new ArrayList [3]; // 3 null elements
I tried all sorts of variations, even tried using
the Arrays newInstance() method, but ... still getting
compilation warnings. I'm obviously missing sumpthin' !
Hey - Thanks !
- Eric