Using a for loop in an arraylist

Discussion in 'Java' started by Ro3, Jun 3, 2008.

  1. Ro3

    Ro3 New Member

    Jun 3, 2008
    Likes Received:
    Trophy Points:
    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!

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice