Error
The method forEach(Consumer<? super [Integer]>) in the type Iterable<[Integer]> is not applicable for the arguments (void)
Error Type
Compile Time ( Java 8 )
Sample Code
List<Integer> intList = new ArrayList<Integer>();
intList.add(4);
intList.add(5);
intList.forEach(System.out.println("BuggyBread"));
Cause
The method forEach should have the argument of type Integer and not Void.
Possible Resolution
Use double colon as following
intList.forEach(System.out::println("BuggyBread"));
or specify the expression as
intList.forEach(e->System.out.println("BuggyBread"));
The method forEach(Consumer<? super [Integer]>) in the type Iterable<[Integer]> is not applicable for the arguments (void)
Error Type
Compile Time ( Java 8 )
Sample Code
List<Integer> intList = new ArrayList<Integer>();
intList.add(4);
intList.add(5);
intList.forEach(System.out.println("BuggyBread"));
Cause
The method forEach should have the argument of type Integer and not Void.
Possible Resolution
Use double colon as following
intList.forEach(System.out::println("BuggyBread"));
or specify the expression as
intList.forEach(e->System.out.println("BuggyBread"));