本文共 1574 字,大约阅读时间需要 5 分钟。
Syntax:
句法:
public int hashCode();
Parameter(s):
参数:
Return value:
返回值:
The return type of this method is int, it returns hash code for this object.
此方法的返回类型为int ,它返回此对象的哈希码。
Example:
例:
// Java program to demonstrate the example // of int hashCode() method of Short classpublic class HashCodeOfShortClass { public static void main(String[] args) { // Variables initialization short value1 = 30; short value2 = 10; // It returns hashcode value denoted by this Short ob1 object // by calling ob1.hashCode() Short ob1 = new Short(value1); // Display ob1 result System.out.println("ob1.hashCode(): " + ob1.hashCode()); // It returns hashcode value denoted by this Short ob2 object // by calling ob2.hashCode() Short ob2 = new Short(value2); // Display ob2 result System.out.println("ob2.hashCode(): " + ob2.hashCode()); }}
Output
输出量
ob1.hashCode(): 30ob2.hashCode(): 10
翻译自:
转载地址:http://jytzd.baihongyu.com/