Re:What's Stopping Me Using Java8 Lambdas – Try Debugging Them
by the8472 on Sunday January 18, 2015 @11:52AM
(#8907942)
List<T>#forEach takes a Consumer<? super T>
Consumer<U> has a single abstract method
void accept(U u)
The lambda effectively is an anonymous class implementing that interface / that single method. U resolves to ? super String. I.e. it expects a method that takes String or a superclass thereof as its first parameter.
That's what e is. It all gets automatically pieced together at compile time via type inference.
Consumer<U> has a single abstract method
void accept(U u)
The lambda effectively is an anonymous class implementing that interface / that single method. U resolves to ? super String. I.e. it expects a method that takes String or a superclass thereof as its first parameter.
That's what e is. It all gets automatically pieced together at compile time via type inference.