No, filter does not scan the whole stream. It's an intermediate operation, which returns a lazy stream (actually all intermediate operations return a lazy stream). To convince you, you can simply do the following test:

List<Integer> list = Arrays.asList(1, 10, 3, 7, 5);
int a = list.stream()
            .peek(num -> System.out.println("will filter " + num))
            .filter(x -> x > 5)
            .findFirst()
            .get();
System.out.println(a);

Which outputs:

will filter 1
will filter 10
10

You see that only the two first elements of the stream are actually processed.

So you can go with your approach which is perfectly fine.

Answer from Alexis C. on Stack Overflow
🌐
GeeksforGeeks
geeksforgeeks.org › java › find-the-first-element-of-a-stream-in-java
Find the first element of a Stream in Java - GeeksforGeeks
July 12, 2025 - To get the first element, you can use the reduce() method to ignore the second element, repeatedly, till there is no second element. ... This reduces the set of elements in a Stream to a single element, which is first.
🌐
Medium
rameshfadatare.medium.com › java-stream-findfirst-method-with-examples-2988f89becc2
Java Stream findFirst() Method with Examples | by Ramesh Fadatare | Medium
September 27, 2024 - To demonstrate the basic usage of findFirst(), we will create a Stream and use findFirst() to retrieve the first element from the stream. import java.util.Optional; import java.util.stream.Stream; public class FindFirstExample { public static ...
🌐
Blogger
javarevisited.blogspot.com › 2016 › 03 › how-to-find-first-element-of-stream-in.html
How to find the first element in Stream in Java 8? findFirst() Example
October 5, 2024 - In Java 8, you can use the Stream.findFirst() method to get the first element of Stream in Java. This is a terminal operation and is often used after applying several intermediate operations e.g. filter, mapping, flattening, etc.
🌐
TutorialsPoint
tutorialspoint.com › find-the-first-element-of-a-stream-in-java
Find the first element of a Stream in Java
July 31, 2023 - Create a stream from the collection of elements. Use the findFirst method to obtain an Optional object with the first element of the stream. Check if the Optional object is empty or contains a value.
🌐
Java67
java67.com › 2018 › 03 › java-8-stream-find-first-and-filter-example.html
Java 8 Stream filter() + findFirst Example Tutorial | Java67
As the problem statement says, ... to achieve that we'll first get the Stream from the List and then call the filter() method with the predicate number > 7, after that we'll call the findFirst() method....
🌐
Dirask
dirask.com › posts › Java-8-find-first-element-in-Stream-that-matches-criteria-10QVOD
Java 8 - find first element in Stream that matches criteria
4 days ago - find the first element in Stream ... the criteria (in our case if the element starts with "B"), findFirst() - to return the first value that matches the criteria, orElse() - to return null if none of the elements matc...
🌐
Blogger
javarevisited.blogspot.com › 2016 › 03 › how-to-find-first-element-of-stream-in.html
Javarevisited: How to find the first element in Stream in Java 8? findFirst() Example
March 7, 2025 - In Java 8, you can use the Stream.findFirst() method to get the first element of Stream in Java. This is a terminal operation and is often used after applying several intermediate operations e.g. filter, mapping, flattening, etc.
🌐
GeeksforGeeks
geeksforgeeks.org › java › stream-findfirst-java-examples
Stream findFirst() in Java with examples - GeeksforGeeks
December 26, 2025 - Example 1: This code demonstrates using Stream.findFirst() to retrieve the first element of a stream, returning an Optional to safely handle empty streams. ... import java.util.*; class GFG { public static void main(String[] args) { List<Integer> ...
Find elsewhere
🌐
Mkyong
mkyong.com › home › java8 › java 8 stream findfirst() and findany()
Java 8 Stream findFirst() and findAny() - Mkyong.com
February 8, 2020 - In Java 8 Stream, the findFirst() returns the first element from a Stream, while findAny() returns any element from a Stream.
🌐
HowToDoInJava
howtodoinjava.com › home › java 8 › java stream findfirst() example
Java Stream findFirst() Example
July 23, 2025 - The Java 8 Stream.findFirst() is a terminal operation that returns an Optional describing the first element of the given stream if stream is non-empty, or an empty Optional if the stream is empty.
🌐
Baeldung
baeldung.com › home › java › java streams › java stream findfirst() vs. findany()
Java Stream findFirst() vs. findAny() | Baeldung
January 9, 2024 - ... The article explains how to convert an Iterable to Stream and why the Iterable interface doesn't support it directly. ... As the name suggests, the findAny() method allows us to find any element from a Stream.
🌐
Scaler
scaler.com › topics › java-stream-findfirst
Java Stream findFirst() - Scaler Topics
Scaler Topics offers free certificate courses for all programming languages like Java, Python, C, C++, DSA etc. Learn from top MAANG experts and level up your skills. Explore now
🌐
javaspring
javaspring.net › blog › java-stream-find-first
Mastering `java.stream` `findFirst`: A Comprehensive Guide
Let's look at some basic usage examples of the findFirst() method. import java.util.Arrays; import java.util.Optional; public class FindFirstExample { public static void main(String[] args) { Integer[] numbers = {1, 2, 3, 4, 5}; Optional<Integer> ...
🌐
Baeldung
baeldung.com › home › java › java collections › get index of first element matching boolean using java streams
Get Index of First Element Matching Boolean Using Java Streams | Baeldung
March 7, 2025 - Learn how to use the Java Stream API and third-party libraries to find the index of the first element in a List that matches a boolean condition.
🌐
Ramesh Fadatare
rameshfadatare.com › home › java 8 – find first and any elements in a stream
Java 8 - Find First and Any Elements in a Stream
January 3, 2023 - Use findAny() to Retrieve Any Element: Apply the findAny() method to get any element from the stream. Compare findFirst() and findAny() in Parallel Streams: Observe the behavior of these methods in a parallel stream. The findFirst() method is used to retrieve the first element from a stream.
🌐
ZetCode
zetcode.com › java › stream-findfirst-findany
Java Stream findFirst/findAny - finding first or any element in Java streams
September 5, 2024 - Both methods help safely extract elements from a stream without causing exceptions when dealing with empty data sets, making them valuable for functional programming approaches in Java. In the next example we use the findFirst method. ... void main() { var words = List.of("war", "cup", "cloud", ...
🌐
Level Up Lunch
leveluplunch.com › java › examples › get-first-element-in-list
Get first element in list | Level Up Lunch
January 31, 2014 - @Test public void get_first_element_in_list_with_java8 () { List<String> strings = new ArrayList<String>(); strings.add("one"); strings.add("two"); strings.add("three"); Optional<String> firstElement = strings.stream().findFirst(); assertEquals("one", firstElement.orElse("two")); }