Java.lang.Double.hashCode() Method


Description

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

Declaration

Following is the declaration for java.lang.Double.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.Double.hashCode() method.

package com.tutorialspoint;

import java.lang.*;

public class DoubleDemo {

   public static void main(String[] args) {

      Double d = new Double("3.08");
    
      // returns a hash code value
      int retval = d.hashCode();
      System.out.println("Value = " + retval);
   }
} 

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

Value = 1245041523
java_lang_double.htm
Advertisements