Category: Java core
How to iterate a List in Java
This tutorial shows several ways for iterating a List in Java. 1- Typical For loop Using a typical For loop, you can iterate a List as the following:
1 2 3 4 5 6 7 | private static void iterateListForLoop(List<String> lstInput) { for(int i=0; i<lstInput.size(); i++) { System.out.println(lstInput.get(i)); } } |
2-...