简体   繁体   中英

What's the exact equivalent of python's native hash() function in Java?

I am trying to convert a Python script I wrote to Java. In the script I am using python's native hash() function on strings. I need to find the exact equivalent of this in Java to avoid discrepancies. Thanks in advance!

The Python method hash(object)

calls __hash__() method of an object which are set by default for any object.


The exact equivalent in Java to that is Objects.hashCode(Object) that calls hashCode() on the given object and returns the result.


The equivalence is given by the syntax. It may not be given by the underlying hashing algorithm.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM