Get the maximum of three int values in Java
Description
The following code shows how to get the maximum of three int values.
Example
// w w w . j a va2s .c o m
public class Main {
/**
* <p>Gets the maximum of three <code>int</code> values.</p>
*
* @param a value 1
* @param b value 2
* @param c value 3
* @return the largest of the values
*/
public static int maximum(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(maximum(1, 2, 3));
}
}
The code above generates the following result.
Home »
Java Tutorial »
Java Data Type »
Java Tutorial »
Java Data Type »