I'm just in the process of re-coding some classes for
java 1.5. They all compiled and worked fine under 1.4, but Im getting compile warnings under 1.5 (even though they still all run correctly). I'm new to Jave 1.5, and it appears that the issue I am having is with generics. I have a class which holds the following ArrayList:
ArrayList records = new ArrayList();
Obviosuly, I get an "unchecked" warning when compiling this, so I do:
ArrayList<Integer> records = new ArrayList<Integer>();
Further on in the code I want to add this ArrayList to another ArrayList, so I try:
ArrayList keepRecords = new ArrayList(records);
Again I get an unchecked warning, so I do:
ArrayList<ArrayList> keepRecords = new ArrayList<ArrayList>(records);
I htink this is correct, because keepRecords is an ArrayList that contains other ArrayLists. However, when i compile I get:
As far as I can see this should be correct. In 1.4 I could create an ArrayList with a another Collection (e.g. An ArrayList),and it worked fine. No matter what I try I can't get this to work. Any help would be much appreciated!
Stephen :-)