📜  带有示例的 Scala String hashCode() 方法

📅  最后修改于: 2022-05-13 01:55:39.793000             🧑  作者: Mango

带有示例的 Scala String hashCode() 方法

hashCode()方法用于查找指定字符串的哈希码。

示例 #1:

// Scala program of int hashCode()
// method
  
// Creating object
object GfG
{ 
  
    // Main method
    def main(args:Array[String])
    {
      
        // Applying hashCode method
        val result = "Nidhi".hashCode()
          
        // Displays output
        println(result)
      
    }
} 
输出:
75262122

示例 #2:

// Scala program of int hashCode()
// method
  
// Creating object
object GfG
{ 
  
    // Main method
    def main(args:Array[String])
    {
      
        // Applying hashCode method
        val result = " ".hashCode()
          
        // Displays output
        println(result)
          
    }
} 
输出:
32