java foreach arraylist code example
Example: ArrayList forEach(Consumer super action) method in java
import java.util.ArrayList;
public class ArrayListForEachMethodExample
{
public static void main(String[] args)
{
ArrayList<Integer> al = new ArrayList<Integer>();
al.add(10);
al.add(50);
al.add(20);
al.add(82);
al.add(75);
// print numbers using forEach method of ArrayList
al.forEach((n) -> System.out.println(n));
}
}