How to iterate a list in java

In this post, we will see how  can we iterate a list in java. There are four ways of iterating over a list.

  • For loop
  • For each loop(Java 5)
  • While loop
  • Iterator
Below example will help you to understand, how to iterate list in java. I am taking custom object list to understand better

1. Country.java 

2. IterateListMain.java 

Run it and you will get following output:

Add Comment