-
Notifications
You must be signed in to change notification settings - Fork 549
Expand file tree
/
Copy pathDesafio4.java
More file actions
22 lines (19 loc) · 780 Bytes
/
Desafio4.java
File metadata and controls
22 lines (19 loc) · 780 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
package stream_api;
import java.util.Arrays;
import java.util.List;
/***
* Desafio 4 - Remova todos os valores ímpares:
* Utilize a Stream API para remover os valores ímpares da lista e imprima a lista resultante no console.
*
*/
public class Desafio4 {
public static void main(String[] args) {
System.out.println(
"-------4- REMOVER TODOS OS ÍMPARES---------");
List<Integer> numeros = Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 5, 4, 3);
System.out.println(
"-----------------------------------------4- REMOVER TODOS OS ÍMPARES----------------------------------");
List<Integer> somentePares = numeros.stream().filter(n -> n % 2 == 0).toList();
System.out.println(somentePares);
}
}