We can use the hashCode()
method is used to calculate the
def hashCode(): Int
int.hashCode()
String.hashCode()
Calling this method returns an integer value which is the hashCode of the specified string/integer.
hashCode
of an integer may be equal to the integer itself.
Let’s have a look at a coding example to understand it further:
object Main extends App {// string hashcodeval result = "Hello".hashCode()println(result)// integer hashcodeval result1 = 123.hashCode()println(result1)}
Free Resources