I'm new to Java and the code I'm working with is largely not my own, so please bear with me...
I have an arraylist containing several dozen instances of the same class, from which I'd like to extract the values of some variables in turn.
I've created an iterator and can iterate happily over the arraylist, the problem comes when I try to extract the class instances. Using .get(index) returns an Object and I'm ignorant of how to either convert an Object to the class type in order to access the variables or extract the instance in its own type.
Can anyone advise how to resolve this?
Thanks in advance.
Edit: sorry, I should have included the code in the first instance.
ArrayList TopicResults = results.getTopicResults(TopicNum);
ListIterator TopicResultsiter = TopicResults.listIterator();
while(TopicResultsiter.hasNext()){
int idx = TopicResultsiter.nextIndex();
ResultsList.Result result = TopicResults.get(idx);
String DocID = result.docID;
System.out.println(DocID);
}