Different Kinds of Streams 4 - iterate an array map the values calculate the average
suggest change// Java:
Arrays.stream(new int[] {1, 2, 3})
.map(n -> 2 * n + 1)
.average()
.ifPresent(System.out::println); // 5.0
// Kotlin:
arrayOf(1,2,3).map { 2 * it + 1}.average().apply(::println)
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents