Scusa ma un metodo getter che ti restituisca la lista es:
codice:classCarimplementsCarElement{ ArrayList<CarElement>lista; publicCar(){ //create new ArrayList of CarElement this.lista =newArrayList<CarElement>(); lista.add(newWheel("front left")); lista.add(newWheel("front right")); lista.add(newWheel("back left")); lista.add(newWheel("back right")); lista.add(newBody()); lista.add(newEngine()); } public ArrayList<CarElement> getLista() { return this.lista; } } publicCarElement prova(Car car){ Iterator<CarElement> itr = car.getLista().iterator(); while(itr.hasNext()){ CarElement element = itr.next(); } }

Rispondi quotando