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