Scala Int hashCode() 方法与示例
hashCode()方法用于返回指定 int 值的哈希值。
Method Definition: def hashCode(): Int
Return Type: It returns hash value of the specified int value.
示例 #1:
// Scala program of Int hashCode
// method
// Creating object
object GfG
{
// Main method
def main(args:Array[String])
{
// Applying hashCode method
val result = (22).hashCode
// Displays output
println(result)
}
}
输出:
22
示例 #2:
// Scala program of Int hashCode
// method
// Creating object
object GfG
{
// Main method
def main(args:Array[String])
{
// Applying hashCode method
val result = (5645).hashCode
// Displays output
println(result)
}
}
输出:
5645