Float hashCode() method in Java with examples
Last Updated :
26 Oct, 2018
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:
class GFG {
public static void main(String[] args)
{
float d = 118 .698f;
Float value = new Float(d);
int output = value.hashCode();
System.out.println( "Hashcode Value of "
+ value + " : "
+ output);
}
}
|
Output:
Hashcode Value of 118.698 : 1122854240
Example 2:
class GFG {
public static void main(String[] args)
{
int i = - 30 ;
Float value = new Float(i);
int output = value.hashCode();
System.out.println( "Hashcode Value of "
+ value + " : "
+ output);
}
}
|
Output:
Hashcode Value of -30.0 : -1041235968
Share your thoughts in the comments
Please Login to comment...