Created
July 28, 2022 13:50
-
-
Save kolebakin/159027e7292cef0cd18bbc1715cc5b0b 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
| public class Task { | |
| /** | |
| * 1. Убрать 5 самых больших значений (Учитывая повторы). | |
| * 2. Убрать дублирующиеся элементы. | |
| * 3. Убрать все чётные значения. | |
| * 4. Получить все элементы единой строкой через запятую. | |
| * | |
| * Все операции должны проходить в рамках одного стрима. | |
| */ | |
| public static void main(String[] args) throws IOException { | |
| final var objects = generateObjects(); | |
| // написать тут стрим, который возвращает стрингу, | |
| не перезапуская стрим, то есть с одной терминальной операцией | |
| } | |
| private static List<List<Object>> generateObjects() { | |
| final var objects = new ArrayList<List<Object>>(); | |
| final var random = new Random(); | |
| final var arrays = random.nextInt(5) + 3; | |
| for (var i = 0; i < arrays; i++) { | |
| final var elements = random.nextInt(20) + 5; | |
| final var list = new ArrayList<>(); | |
| for (var j = 0; j < elements; j++) { | |
| list.add(random.nextInt(1000)); | |
| } | |
| objects.add(list); | |
| } | |
| return objects; | |
| } | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment