OptionalLong hashCode() method in Java with examples
The hashCode() method help us to get the hash code of the value, if Long value is present, otherwise 0 (zero) if no Long value is present in OptionalLong object.
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.
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:
OptionalLong: OptionalLong HashCode value: 253255
OptionalLong: OptionalLong.empty HashCode value: 0