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