Optional<String> name = Optional.ofNullable(getName());
| Interface | Purpose | Example Lambda | | :--- | :--- | :--- | | | Takes an argument, returns boolean | s -> s.isEmpty() | | Consumer | Takes an argument, returns nothing (void) | s -> System.out.println(s) | | Function<T,R> | Takes T, returns R | s -> s.length() | | Supplier | Takes nothing, returns T | () -> new User() | | UnaryOperator | Takes T, returns T | s -> s.trim() | | BinaryOperator | Takes two T's, returns T | (a, b) -> a + b |
All-in-one for time, projects, invoices, quotes & expenses.
Try HeyGopher free →Optional<String> name = Optional.ofNullable(getName());
| Interface | Purpose | Example Lambda | | :--- | :--- | :--- | | | Takes an argument, returns boolean | s -> s.isEmpty() | | Consumer | Takes an argument, returns nothing (void) | s -> System.out.println(s) | | Function<T,R> | Takes T, returns R | s -> s.length() | | Supplier | Takes nothing, returns T | () -> new User() | | UnaryOperator | Takes T, returns T | s -> s.trim() | | BinaryOperator | Takes two T's, returns T | (a, b) -> a + b | java environment 1.8.0