1. We have moved from vBulletin to XenForo and you are viewing the site in the middle of the move. Though the functional aspect of everything is working fine, we are still working on other changes including the new design on Xenforo.
    Dismiss Notice

Using a for loop in an arraylist

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

  1. Ro3

    Ro3 New Member

    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