Answers for "ArrayList forEach(Consumer super action) method in java"

1

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));
   }
}
Posted by: Guest on October-29-2020
1

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));
   }
}
Posted by: Guest on October-29-2020

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language