Re: ArrayList.get help ?



TonyB wrote:
Further to my earlier questions on ArrayLists, I have now created an ArrayList containing a number of Tool objects, and now I'm trying to do some tests on each list items.
So I find the size of the list, run a for loop, and for each iteration of the loop try to load the object in that position in the list, and then do some tests on that object.
by using something like
private ArrayList toolList ;
private Tool currentTool ;
.....
numberOfElements = toolList.size() ;
for(i=0; i<numberOfElements; i++){
currentTool = toolList.get(i) ;
currentTool.method()
.....
The compiler complains for the line containing toolList.get(i) "incompatible types - found java.lang.Object but expected Tool"

private ArrayList<Tool> toolList ;
.