1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Using a for loop in an arraylist

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

  1. Ro3

    Ro3 New Member

    Joined:
    Jun 3, 2008
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    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:

    Code:
    //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());
    	
    	
    	
    	//tekenen
    	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