Skip to content
Related Articles

Related Articles

Scala String hashCode() method with example
  • Last Updated : 03 Oct, 2019

The hashCode() method is utilized to find the hash code of the stated string.

Method Definition: int hashCode()
Return Type: It returns an integer hash code of the string given.

Example #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)
      
    }
Output:
75262122

Example #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)
          
    }
Output:
32



My Personal Notes arrow_drop_up
Recommended Articles
Page :