IteratingListUsingForeachLoop.java

package com.dineshkrish;
import java.util.ArrayList;
import java.util.List;
public class IteratingListUsingForeachLoop {
public static void main(String[] args) {
List<String> strList = new ArrayList<String>();
strList.add("One");
strList.add("Two");
strList.add("Three");
strList.add("Four");
strList.add("Five");
strList.add("Six");
for(String strValue : strList) {
System.out.println(strValue);
}
}
}

Output

—————–
One
Two
Three
Four
Five
Six

Tags:

No responses yet

Leave a Reply

Your email address will not be published. Required fields are marked *