lr11 -> task_1 -> e5-10
This commit is contained in:
22
lr11/task_1/e8.java
Normal file
22
lr11/task_1/e8.java
Normal file
@@ -0,0 +1,22 @@
|
||||
package lr11.task_1;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class e8 {
|
||||
public static List<Integer> filterGreaterThan(List<Integer> numbers, int threshold) {
|
||||
return numbers.stream()
|
||||
.filter(n -> n > threshold)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
List<Integer> numbers = List.of(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
|
||||
int threshold = 5;
|
||||
|
||||
List<Integer> result = filterGreaterThan(numbers, threshold);
|
||||
|
||||
System.out.println("Числа, большие " + threshold + ":");
|
||||
result.forEach(System.out::println);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user