Class Demo_ForEach


  • public class Demo_ForEach
    extends Object
    Demo showing the implementation of a higher-order function forEach
    Author:
    Herbert Praehofer
    • Constructor Detail

      • Demo_ForEach

        public Demo_ForEach()
    • Method Detail

      • printEach

        static <E> void printEach​(List<E> list)
        Prints the elements of a list.
        Type Parameters:
        E - the type of elements
        Parameters:
        list - the list of elements to print.
      • forEach

        static <E> void forEach​(List<E> list,
                                Consumer<E> action)
        Executes an action for the elements of a list.
        Type Parameters:
        E - the type of elements
        Parameters:
        list - the list of elements
        action - the function object to execute on the elements
      • main

        public static void main​(String[] args)