Max, min value

static double max(double a, double b)
Returns the greater of two double values.
static float max(float a, float b)
Returns the greater of two float values.
static int max(int a, int b)
Returns the greater of two int values.
static long max(long a, long b)
Returns the greater of two long values.
static double min(double a, double b)
Returns the smaller of two double values.
static float min(float a, float b)
Returns the smaller of two float values.
static int min(int a, int b)
Returns the smaller of two int values.
static long min(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
Home 
  Java Book 
    Essential Classes  

Math:
  1. Math class
  2. Constant E and PI
  3. Get the absolute value
  4. sin, cos, tan: Trigonometric functions
  5. Cube root and square root
  6. Ceilling and flooring value
  7. Copy sign
  8. Raise the power
  9. Get exponent
  10. sqrt(x2 +y2)
  11. IEEE remainder
  12. logarithm
  13. Max, min value
  14. Next value
  15. Math Random
  16. Round to int to double
  17. Round a value to integer
  18. value * 2^ scaleFactor
  19. Get the sign
  20. Degree to Radian, and Radian to Degree
  21. Returns the size of an ulp of the argument