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  .jav  a 2s  .  com

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.





















Home »
  Java Tutorial »
    java.lang »




Boolean
Byte
Character
Class
Double
Enum
Float
Integer
Long
Math
Number
Object
Package
Process
ProcessBuilder
Runnable
Runtime
SecurityManager
Short
StackTraceElement
StrictMath
String
StringBuffer
StringBuilder
System
Thread
ThreadGroup
ThreadLocal
Throwable