I have an ArrayList for type Room (my custom object) Defined as below
ArrayList<Room> rooms = new ArrayList<Room>();
After then adding a series of objects to the ArrayList I want to go through them all and check various things. I am not a keen user of java but I know in many other programming languages a foreach loop would be the most simple way of doing this.
After a bit of research I found the following link which suggests the code below. How does the Java 'for each' loop work?
for(Iterator<String> i = someList.iterator(); i.hasNext(); ) {
String item = i.next();
System.out.println(item);
}
But as far as I can tell this cant be used for an Arraylist of a custom object.
Can, and if so how can I implement a foreach loop for an ArrayList of a custom object? Or how could I otherwise process each item?