Package at.jku.ssw.fp.sect04_0
Class Demo_ForEach
- java.lang.Object
-
- at.jku.ssw.fp.sect04_0.Demo_ForEach
-
public class Demo_ForEach extends Object
Demo showing the implementation of a higher-order function forEach- Author:
- Herbert Praehofer
-
-
Constructor Summary
Constructors Constructor Description Demo_ForEach()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description (package private) static <E> void
forEach(List<E> list, Consumer<E> action)
Executes an action for the elements of a list.static void
main(String[] args)
(package private) static <E> void
printEach(List<E> list)
Prints the elements of a list.
-
-
-
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 elementsaction
- the function object to execute on the elements
-
main
public static void main(String[] args)
-
-