OptionalInt orElse(int) method in Java with examples
The orElse(int) method helps us to get the value in this OptionalInt object. If a value is not present in this OptionalInt, then this method returns the value passed as the parameter.
public int orElse(int other)
Parameters: This method accepts int the value to be returned, if no value is present.
Return value: This method returns the value, if present, otherwise other.
Below programs illustrate toString() method:
Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more, please refer Complete Interview Preparation Course.