Prototype: firstPositive(List<Integer>) -> OptionalInt returns the first value >0 in encounter order or empty. Preserve list.
Final: firstMatching(Stream<Integer>,Predicate<Integer>) -> OptionalInt takes ownership of an ordered stream, forces sequential processing, and returns the first matching integer. Invoke the predicate exactly once on each visited value and never on values after the first match. Close the stream exactly once on success, exhaustion, or predicate failure. Propagate predicate exceptions unchanged; do not materialize the full stream. Null values outside domain.
Drag or use the arrow keys to resize. Home collapses the question; End collapses the editor. Enter or double-click resets the split.
Loading editor…
Loading editor…
No results yet.
Complete the starter code, then run the checks.
Results and errors will appear here.
Java runs on this device with CheerpJ 4.3.