ArrayList forEach(Consumer super action) method in java
import java.util.ArrayList;
public class ArrayListForEachMethodExample
{
public static void main(String[] args)
{
ArrayList<String> colors = new ArrayList<String>();
colors.add("red");
colors.add("blue");
colors.add("green");
colors.add("yellow");
System.out.println("list of colors: ");
// forEach method of ArrayList
colors.forEach((n) -> System.out.println(n));
}
}