Float.min() in Java

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

Syntax:

float java.lang.Float.min(float a, float b)

This method takes two arguments of type float as its parameters. This method returns the smaller of two float values.

Parameters: Two parameters are required for this method.

a: the first operand.

b: the second operand.

Returns: the smaller of a and b.

Approach

Java

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

        float a = 1919.56f, b = 1991.5f;
        System.out.println(Float.min(a, b));

    }
}

Output:

1919.56

No comments:

Post a Comment