Max, min value

ReturnMethodSummary
static doublemax(double a, double b)Returns the greater of two double values.
static floatmax(float a, float b)Returns the greater of two float values.
static intmax(int a, int b)Returns the greater of two int values.
static longmax(long a, long b)Returns the greater of two long values.
static doublemin(double a, double b)Returns the smaller of two double values.
static floatmin(float a, float b)Returns the smaller of two float values.
static intmin(int a, int b)Returns the smaller of two int values.
static longmin(long a, long b)Returns the smaller of two long values.

public class Main {
  public static void main(String[] args) {

    System.out.println(Math.max(2,1.2));
    System.out.println(Math.min(2,1.2));
  }
}

The output:


2.0
1.2
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.