Float.hashCode() in Java

Float.hashCode(): This method is available in java.lang.Float class of Java.

Syntax:

int java.lang.Float.hashCode(float value)

This method takes one argument of type float as its parameter. This method returns a hash code for a float value.

Parameters: One parameter is required for this method.

value: the value to hash.

Returns: a hash code value for the float value.

For Example:

float value = (float) 15.7

Float.hashCode(value) = > It returns 1098593075.

Approach

Java

public class FloathasCode {
    public static void main(String[] args) {

        float value = (float15.7;
        System.out.println(Float.hashCode(value));

    }
}

Output:

1098593075

No comments:

Post a Comment