Follow along with the video below to see how to install our site as a web app on your home screen.
Anmerkung: This feature may not be available in some browsers.
Random rand = new Random();
IntStream nums = rand.ints(10, 0, 100);
nums.filter(x -> x%2 == 0).map(x -> x*2).forEach(System.out::println);
nums.filter(
new IntPredicate() {
public boolean test(int x) {
return x%2 == 0;
}
}).map(
new IntUnaryOperator() {
public int applyAsInt(int x) {
return x*2;
}
}).forEach(
new IntConsumer() {
public void accept(int x) {
System.out.println(x);
}
});
public class Test {
private static int fib(int n) {
if(n < 2) return n;
else return fib(n-1) + fib(n-2);
}
public static void main(String[] args) {
List<Integer> list = Arrays.asList(38,39,40,41,42,43,44,45);
long start = System.nanoTime();
list.stream().parallel().map(Test::fib).forEach(System.out::println);
long end = System.nanoTime();
double time = (end-start)/1e9;
System.out.println("time = " + time);
}
}
list.stream().parallel().map(Test::fib).forEach(System.out:😛rintln);
list.parallelStream().map(Test::fib).forEachOrdered(System.out::println);