Hashcode of an int

后端 未结 4 1234
[愿得一人]
[愿得一人] 2020-12-09 02:34

What is the hashcode of a primitive type, such as int?

for example, let\'s say num was an interger.

int hasCode = 0;

if (num != 0) {
  hasCode = has         


        
4条回答
  •  甜味超标
    2020-12-09 03:29

    For the hashCode of an int the most natural choice is to use the int itself. A better question is what to use for the hashCode of a long since it doesn't fit into the int-sized hashcode. Your best source for that—and all hashCode-related questions—would be Effective Java.

提交回复
热议问题