Java Data Type Tutorial - Java Math.min(float a, float b)








Syntax

Math.min(float a, float b) has the following syntax.

public static float min(float a, float b)

Example

In the following code shows how to use Math.min(float a, float b) method.

//  w  w w.  j  a  v  a  2s  . co m

public class Main {

   public static void main(String[] args) {

      // get two float numbers
      float x = 1234.567f;
      float y = 123.456f;

      // print the smaller number between x and y
      System.out.println("Math.min(" + x + "," + y + ")=" + Math.min(x, y));

   }
}

The code above generates the following result.