ArrayList array = new ArrayList();
Iterator it1 = array.iterator();
while (it1.hasNext()){
Myclass temp = it1.myGetterMethod();
System.out.println (temp);
}
This is what I would like to implement, but Iterator only returns a generic Object. When I call Object.getClass(), the class is Myclass. Does this mean that the Iterator is not generic, and I need extend the Iterator class whenever I’m iterating objects that aren’t Java strings etc?
You did not create a generic ArrayList.
Try