Java Math.min(long a, long b)

Syntax

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

public static long min(long a, long b)

Example

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


//from   w w w.  j  a  v a2  s  .c om
public class Main {

   public static void main(String[] args) {

      long x = 123456789098877l;
      long y = 123456789098771l;

      // 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