java.lang.Byte.hashCode() 方法返回与 Byte 兼容的字节值的哈希码。 hashCode().
语法
public static int hashCode(byte value)
参数
值 | 指定要哈希的值。 |
返回值
返回字节值的哈希代码值。
异常
不适用。
示例:
在下面的示例中,java.lang.Byte.hashCode() 方法返回给定字节值的哈希码。
import java.lang.*;
public class MyClass {
public static void main(String[] args) {
//创建字节值
byte val1 = 25;
byte val2 = -25;
//打印字节值的哈希码
System.out.println("hashCode of the val1 is: " + Byte.hashCode(val1));
System.out.println("hashCode of the val2 is: " + Byte.hashCode(val2));
}
}
上述代码的输出将是:
hashCode of the val1 is: 25
hashCode of the val2 is: -25