Wednesday, January 21, 2026
HomeLanguagesJavaFloat hashCode() method in Java with examples

Float hashCode() method in Java with examples

The hashCode() method method in Float Class is a built-in method in Java that return the hashcode value of this Float object.

Syntax:

public int hashCode()

Parameters: It takes no parameters.

Returns: The function returns a hash code value for this object.

Below is the implementation of hashCode() method:

Example 1:




// Java code to demonstrate
// Float hashCode() Method
  
class GFG {
    public static void main(String[] args)
    {
  
        float d = 118.698f;
  
        // creating Float object.
        Float value = new Float(d);
  
        // hashCode() method Float class
        int output = value.hashCode();
  
        // printing the output
        System.out.println("Hashcode Value of "
                           + value + " : "
                           + output);
    }
}


Output:

Hashcode Value of 118.698 : 1122854240

Example 2:




// Java code to demonstrate
// Float hashCode() Method
  
class GFG {
    public static void main(String[] args)
    {
  
        int i = -30;
  
        // creating Float object.
        Float value = new Float(i);
  
        // hashCode() method Float class
        int output = value.hashCode();
  
        // printing the output
        System.out.println("Hashcode Value of "
                           + value + " : "
                           + output);
    }
}


Output:

Hashcode Value of -30.0 : -1041235968
Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Dominic
32475 POSTS0 COMMENTS
Milvus
119 POSTS0 COMMENTS
Nango Kala
6847 POSTS0 COMMENTS
Nicole Veronica
11977 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12064 POSTS0 COMMENTS
Shaida Kate Naidoo
6986 POSTS0 COMMENTS
Ted Musemwa
7220 POSTS0 COMMENTS
Thapelo Manthata
6933 POSTS0 COMMENTS
Umr Jansen
6912 POSTS0 COMMENTS