lr11 -> task_1 -> e2-4
This commit is contained in:
21
lr11/task_1/e4.java
Normal file
21
lr11/task_1/e4.java
Normal 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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user