Java Data Type Tutorial - Java Short.hashCode()








Syntax

Short.hashCode() has the following syntax.

public int hashCode()

Example

In the following code shows how to use Short.hashCode() method.

public class Main{
/*from w  w  w .  ja va  2  s .  c  o m*/
   public static void main(String[] args) {
     short shortNum1 = 150;
     Short ShortObj1 = new Short(shortNum1);
  
     int hcode = ShortObj1.hashCode(); 
     System.out.println("Hashcode for this Short ShortObj1 = " + hcode);
  }
}

The code above generates the following result.