Check out example codes for "ArrayList forEach(Consumer super action) method in java". It will help you in understanding the concepts better.

Code Example 1

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));
   }
}

Code Example 2

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));
   }
}

Learn ReactJs, React Native from akashmittal.com