Created
September 19, 2020 15:03
-
-
Save ucguy4u/b2bb17f5725d03b8b638a2829398da40 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.ucguy4u.functional.java; | |
import java.util.Arrays; | |
import java.util.stream.IntStream; | |
import java.util.stream.Stream; | |
/** | |
* | |
* @author chauhanuday | |
*/ | |
public class Lambdas_06 { | |
public static void main(String[] args) { | |
IntStream.range(1, 4).forEach(System.out::println); | |
// find the average of the numbers squared | |
Arrays.stream(new int[] { 1, 2, 3, 4 }).map(n -> n * n).average().ifPresent(System.out::println); | |
// map doubles to ints | |
Stream.of(1.5, 2.3, 3.7).mapToInt(Double::intValue).forEach(System.out::println); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment