Facebook Page Twitter Page LinkedIn Page
× Java.lang Package Classes


The java.lang.Float.min() method is used to return the smaller of two float values as if by calling Math.min.

Syntax

public static float min(float a,
                        float b)

Parameters

a Specify the first operand.
b Specify the second operand.

Return Value

Returns the smaller of a and b.

Exception

NA.

Example:

In the below example, the java.lang.Float.min() method is used to return the smaller of passed two float arguments.

import java.lang.*;

public class MyClass {
  public static void main(String[] args) {
    
    //creating float values
    float x = 5.2f;
    float y = 10.2f;

    //printing the min of two float values
    System.out.println("min(x, y) = " + Float.min(x, y));   
  }
}

The output of the above code will be:

min(x, y) = 5.2

❮ Java.lang - Float