Open In App

Scala Int hashCode() method with example

Last Updated : 30 Jan, 2020
Improve
Improve
Like Article
Like
Save
Share
Report

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


Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads