Optional

A container that explicitly represents either one non-null value or no value.

What is Optional in Java?

Optional — A container that explicitly represents either one non-null value or no value.

import java.util.Optional;

class Profile {
    Optional<String> nickname = Optional.of("Ace");
}

Level: Freelancer · More Java terms at this level

Updated