Last active
December 7, 2019 16:51
-
-
Save RMuskovets/ecfd63f29332d2c99f9312ace0b12a79 to your computer and use it in GitHub Desktop.
Решение задачи JavaRush Java Core ур3 лекция 11 - Сортировка четных чисел из файла
This file contains 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.nio.file.*; | |
import java.util.*; | |
import java.util.stream.*; | |
public class Solution { | |
public static void main(String[] args) throws Exception { | |
Files.readAllLines(Paths.get(new Scanner(System.in).nextLine())).stream() | |
.mapToInt(Integer::parseInt) // String -> int | |
.filter(x -> x % 2 == 0) // лишаем только четные | |
.sorted() // сортируем | |
.forEach(System.out::println); // выводим на экран | |
} | |
} |
This file contains 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.nio.file.*; | |
import java.util.*; | |
import java.util.stream.*; | |
public class Solution { | |
public static void main(String[] args) throws Exception { | |
Files.readAllLines(Paths.get(new Scanner(System.in).nextLine())).stream().mapToInt(Integer::parseInt).filter(x -> x % 2 == 0).sorted().forEach(System.out::println); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment