Table of Contents

Functional Programming - FindFirst

About

This page is about the FindFirst function in the functional programming paradigm.

As its name indicates, it will find the first element in the collection.

It's generally followed by a delivery function such as:

Example

Java: FindFirst or throw

Example in Java:

list
  .stream()
  .filter(txt -> txt.startsWith(startsWith))
  .findFirst()
  .orElseThrow(() -> new NoSuchElementException("No element found"));