Skip to content

Tag Archives: Java-Optional

The empty() method of java.util.Optional class in Java is used to get an empty instance of this Optional class. This instance do not contain any… Read More
The orElseGet() method of java.util.Optional class in Java is used to get the value of this Optional instance if present. If there is no value… Read More
The hashCode() method of java.util.Optional class in Java is used to get the hashCode value of this Optional instance. If there is no value present… Read More
The toString() method of java.util.Optional class in Java is used to get the string representation of this Optional instance. Syntax: public String toString() Parameters: This… Read More
The equals() method of java.util.Optional class in Java is used to check for equality of this Optional with the specified Optional. This method takes an… Read More
The stream() method of java.util.Optional class in Java is used to get the sequential stream of the only value present in this Optional instance. If… Read More
The or() method of java.util.Optional class in Java is used to get this Optional instance if any value is present. If there is no value… Read More
The ifPresentOrElse(Consumer, Runnable) method of java.util.Optional class helps us to perform the specified Consumer action the value of this Optional object. If a value is… Read More
The get() method of java.util.Optional class in Java is used to get the value of this Optional instance. If there is no value present in… Read More
The filter() method of java.util.Optional class in Java is used to filter the value of this Optional instance by matching it with the given Predicate,… Read More
The orElse() method of java.util.Optional class in Java is used to get the value of this Optional instance, if present. If there is no value… Read More
The isPresent() method of java.util.Optional class in Java is used to find out if there is a value present in this Optional instance. If there… Read More
The orElseThrow() method of java.util.Optional class in Java is used to get the value of this Optional instance if present. If there is no value… Read More
The ofNullable() method of java.util.Optional class in Java is used to get an instance of this Optional class with the specified value of the specified… Read More
The of() method of java.util.Optional class in Java is used to get an instance of this Optional class with the specified value of the specified… Read More