How to iterate a list in java

Previous
Next

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:

Previous
Next

Join Our News Letter - Stay Updated

Subscribe to Awesome Java Content.

Add Comment

Join Our News Letter - Stay Updated

Subscribe to Awesome Java Content.
You can like our facebook page Java2blog