Java Lambda - BooleanSupplier getAsBoolean example








BooleanSupplier getAsBoolean gets a result as boolean type from the functional interface.

Syntax

getAsBoolean has the following syntax.

boolean getAsBoolean()

Example

The following example shows how to use getAsBoolean.

import java.util.function.BooleanSupplier;

public class Main {
  public static void main(String[] args) {
    BooleanSupplier bs = () -> true;
    System.out.println(bs.getAsBoolean());
  }
}

The code above generates the following result.