I am getting the following warning from my Java code:
Lexer.java:591: warning: [unchecked] unchecked conversion
found : java.util.ArrayList
required: java.util.ArrayList<java.lang.Integer>
ArrayList<Integer> tempArray = temp.get(theToken);
I’ve tried casting it to ArrayList but this doesn’t matter, it still appears.
How can I get rid of this?
ArrayList is a Java Collection and can hold any type of object. The get method of temp is presumably declared to return a plain ArrayList but you are specifying tempArray be an ArrayList holding only integers.
If you wrote the class for temp then the get method needs to be declared to return an
ArrayList<Integer>If you didn’t then you will have to make tempArray a plain ArrayList without a generic type of integer.
See http://java.sun.com/docs/books/tutorial/java/generics/index.html for more information on generic types in Java.
On caveat – The generic type checking in java is compile time only, it isn’t present at runtime (so called type erasure).