OptionalInt hashCode() method in Java with examples
The hashCode() method help us to get the hash code of the value, if Int value is present, otherwise 0 (zero) if no Int value is present in OptionalInt object.
public int hashCode()
Parameters: This method accepts does not accepts any parameter.
Return value: This method returns hash code value of the present value or 0 if no value is present.
Below programs illustrate hashCode() method:
OptionalInt: OptionalInt HashCode value: 253
OptionalInt: OptionalInt.empty HashCode value: 0
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.