Skip to content
Related Articles

Related Articles

Scala Int hashCode() method with example
  • Last Updated : 30 Jan, 2020

The hashCode() method is utilized to return hash value of the specified int value.

Method Definition: def hashCode(): Int

Return Type: It returns hash value of the specified int value.

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



22

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

Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.

My Personal Notes arrow_drop_up
Recommended Articles
Page :