Java Math.max(long a, long b)

Syntax

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

public static long max(long a, long b)

Example

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


//from w  ww  . j a  va 2 s  . c  o  m
public class Main {

   public static void main(String[] args) {

      // get two long numbers
      long x = 1234567890123l;
      long y = 9876543210123l;

      // print the larger number between x and y
      System.out.println("Math.max(" + x + "," + y + ")=" + Math.max(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