Update all new Tasks
This commit is contained in:
parent
00a190b0a6
commit
91df62d461
5697 changed files with 93386 additions and 804 deletions
|
|
@ -0,0 +1,17 @@
|
|||
import java.util.List;
|
||||
import java.util.function.IntSupplier;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
import static java.util.stream.Collectors.toList;
|
||||
|
||||
public interface ValueCapture {
|
||||
public static void main(String... arguments) {
|
||||
List<IntSupplier> closures = IntStream.rangeClosed(0, 10)
|
||||
.<IntSupplier>mapToObj(i -> () -> i * i)
|
||||
.collect(toList())
|
||||
;
|
||||
|
||||
IntSupplier closure = closures.get(3);
|
||||
System.out.println(closure.getAsInt()); // prints "9"
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue