OptionalDouble (Java SE 10 & JDK 10 ) (original) (raw)

public final class OptionalDouble
extends Object
A container object which may or may not contain a double value. If a value is present, isPresent() returns true. If no value is present, the object is considered empty andisPresent() returns false.
Additional methods that depend on the presence or absence of a contained value are provided, such as orElse() (returns a default value if no value is present) andifPresent() (performs an action if a value is present).
This is a value-based class; use of identity-sensitive operations (including reference equality (==), identity hash code, or synchronization) on instances ofOptionalDouble may have unpredictable results and should be avoided.
API Note:
OptionalDouble is primarily intended for use as a method return type where there is a clear need to represent "no result." A variable whose type isOptionalDouble should never itself be null; it should always point to an OptionalDouble instance.
Since:
1.8

Report a bug or suggest an enhancement
For further API reference and developer documentation see the Java SE Documentation, which contains more detailed, developer-targeted descriptions with conceptual overviews, definitions of terms, workarounds, and working code examples.
Java is a trademark or registered trademark of Oracle and/or its affiliates in the US and other countries.
Copyright © 1993, 2018, Oracle and/or its affiliates, 500 Oracle Parkway, Redwood Shores, CA 94065 USA.
All rights reserved. Use is subject to license terms and the documentation redistribution policy.