В чем причина ошибки IntPredicate cannot be resolved to a type Java
Прошу помочь выполнить пример. Привожу его как есть из книги И.Н. Блинов, В.С. Романчик - JAVA FROM EPAM (2020). VSC выдает ошибку "IntPredicate cannot be resolved to a type Java(16777218)". java version "17.0.2" 2022-01-18 LTS
int[] arrayInt = {1, 3, 5, 9, 17, 33, 65};
System.out.println(Arrays.stream(arrayInt)
.filter(((IntPredicate) i -> i > 32).or(i -> i < 4))
.boxed()
.collect(Collectors.toList()));
Ответы (1 шт):
Автор решения: Spatz
→ Ссылка
В примерах обычно пропускают импорты:
import java.util.Arrays;
import java.util.function.IntPredicate;
import java.util.stream.Collectors;
public class Main {
public static void main(String[] args) {
int[] arrayInt = {1, 3, 5, 9, 17, 33, 65};
System.out.println(Arrays.stream(arrayInt)
.filter(((IntPredicate) i -> i > 32).or(i -> i < 4))
.boxed()
.collect(Collectors.toList()));
}
}