Here you can find the source of max(int a, int b)
Parameter | Description |
---|---|
a | value. |
b | value. |
public static int max(int a, int b)
//package com.java2s; //License from project: LGPL public class Main { /**//from w ww .j a v a 2s . co m * Returns the bigger number of a and b. * @param a value. * @param b value. * @return max */ public static int max(int a, int b) { return a > b ? a : b; } /** * Returns the bigger number of a, b and c. * @param a value. * @param b value. * @param c value. * @return max */ public static int max(int a, int b, int c) { return max(max(a, b), c); } /** * Returns the biggest number contained in the provided array. * @param numbers Array of numbers * @return max */ public static int max(int... numbers) { if (numbers.length < 1) { throw new IllegalArgumentException(); } int max = numbers[0]; for (int i = 1; i < numbers.length; i++) { if (numbers[i] > max) { max = numbers[i]; } } return max; } /** * Returns the bigger number of a and b. * @param a value. * @param b value. * @return max */ public static double max(double a, double b) { return a > b ? a : b; } /** * Returns the bigger number of a, b and c. * @param a value. * @param b value. * @param c value. * @return max */ public static double max(double a, double b, double c) { return max(max(a, b), c); } /** * Returns the biggest number contained in the provided array. * @param numbers Array of numbers * @return max */ public static double max(double... numbers) { if (numbers.length < 1) { throw new IllegalArgumentException(); } double max = numbers[0]; for (int i = 1; i < numbers.length; i++) { if (numbers[i] > max) { max = numbers[i]; } } return max; } /** * Returns the bigger number of a and b. * @param a value. * @param b value. * @return max */ public static float max(float a, float b) { return a > b ? a : b; } /** * Returns the bigger number of a, b and c. * @param a value. * @param b value. * @param c value. * @return max */ public static float max(float a, float b, float c) { return max(max(a, b), c); } /** * Returns the biggest number contained in the provided array. * @param numbers Array of numbers * @return max */ public static float max(float... numbers) { if (numbers.length < 1) { throw new IllegalArgumentException(); } float max = numbers[0]; for (int i = 1; i < numbers.length; i++) { if (numbers[i] > max) { max = numbers[i]; } } return max; } }