Go4Expert (http://www.go4expert.com/)
-   Java (http://www.go4expert.com/forums/java/)
-   -   Using a for loop in an arraylist (http://www.go4expert.com/forums/using-loop-arraylist-t11052/)

Ro3 3Jun2008 18:20

Using a for loop in an arraylist
Hello, I'm having some beginner dificulties with programming an arraylist to draw certain objects from subclasses.
In my paint method I want to use a for loop to walk through my arraylist and draw these objects, like this:


//een arraylist die wordt gevuld met de bewegendedelen
        ArrayList<BewegendeDelen> bewegendedelenarray = new ArrayList<BewegendeDelen>();
        //voeg de ruimteschip en alien objecten toe aan de arraylist
        bewegendedelenarray.add(new Ruimteschip());
        bewegendedelenarray.add(new Alien());
        public void paint(Graphics G)
                for(BewegendeDelen obj : bewegendedelenarray)
                {        //teken de bewegende delen (ruimteschip, aliens)

How will I get this working?!
thanks in advance!

All times are GMT +5.5. The time now is 08:54.