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
| import java.util.Arrays; | |
| import java.util.stream.Collectors; | |
| public class ex2 { | |
| public static void main(String[] args) { | |
| var a = Arrays.asList(1, 2, 3, 5); | |
| var result = a.stream().filter(i -> i % 2 == 1); | |
| System.out.println( |
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
| import java.util.Arrays; | |
| public class ex3 { | |
| public static void main(String args[]) { | |
| var a = Arrays.asList(1, 2, 3, 5); | |
| var result = a.stream().reduce(1, (s, i) -> s * i); | |
| System.out.println(result); | |
| } |
OlderNewer