Get the minimum of three int values in Java
Description
The following code shows how to get the minimum of three int values.
Example
/*from w w w . ja va2s . c o m*/
public class Main {
/**
* <p>Gets the minimum of three <code>int</code> values.</p>
*
* @param a value 1
* @param b value 2
* @param c value 3
* @return the smallest of the values
*/
public static int minimum(int a, int b, int c) {
if (b < a) {
a = b;
}
if (c < a) {
a = c;
}
return a;
}
public static void main(String[] argv){
System.out.println(minimum(1, 2, 3));
}
}
The code above generates the following result.
Home »
Java Tutorial »
Java Data Type »
Java Tutorial »
Java Data Type »