Java.lang.Short.hashCode() Method

Advertisements


Description

The java.lang.Short.hashCode() method returns a hash code for this Short.

Declaration

Following is the declaration for java.lang.Short.hashCode() method

public int hashCode()

Parameters

  • NA

Return Value

This method returns a hash code value for this object.

Exception

  • NA

Example

The following example shows the usage of java.lang.Short.hashCode() method.

package com.tutorialspoint;

import java.lang.*;

public class ShortDemo {

   public static void main(String[] args) {

     // create short object and assign value to it
     short shortNum1 = 150;
     Short ShortObj1 = new Short(shortNum1);
  
     // returns hashcode
     int hcode = ShortObj1.hashCode(); 
     System.out.println("Hashcode for this Short ShortObj1 = " + hcode);
  }
}   

Let us compile and run the above program, this will produce the following result:

Hashcode for this Short ShortObj1 = 150



Advertisements
Advertisements