lr11 -> task_1 -> e2-4

This commit is contained in:
2026-04-07 21:06:51 +05:00
parent d114be3232
commit 1d32229ad9
3 changed files with 66 additions and 0 deletions

21
lr11/task_1/e4.java Normal file
View File

@@ -0,0 +1,21 @@
package lr11.task_1;
import java.util.List;
import java.util.stream.Collectors;
public class e4 {
public static List<Integer> getSquares(List<Integer> numbers) {
return numbers.stream()
.map(n -> n * n)
.collect(Collectors.toList());
}
public static void main(String[] args) {
List<Integer> numbers = List.of(1, 2, 3, 4, 5, 10);
List<Integer> squares = getSquares(numbers);
System.out.println("Квадраты чисел:");
squares.forEach(System.out::println);
}
}