If you want to filter the stream by to print lines after matching specific value maybe stream is not the best way to do it. It is not intended to keep state and you need to keep a state here (have you already reached the value).
You can do it with streams and filters like that:
public class MainClass {
public static void main(String[] args) {
System.out.println(new Date()+": Let's start our StackOverflow helper project!");
List<String> res= Arrays.asList("house","Tree","Pillow","Sky");
BooleanWrapper valueFound = new BooleanWrapper();
List<String> result = res.stream()
.filter(string -> valueFound.value || "Pillow".equals(string) && (valueFound.value = true))
.collect(Collectors.toList());
result.forEach(System.out::println);
}
}
class BooleanWrapper {
boolean value=false;
}
Notice how we need to wrap our boolean value into a class. If we just use primitive we need to define it as final in order to access it in the stream and that means we cannot change it to true when we find it.
Also this is kind of a hack. It works because we do the assignment valueFound.value = true
last in the filter and it happens ONLY if the other conditions are met. If we change the order of the boolean tests there it will not work.