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