Advertisement
Guest User

Untitled

a guest
Dec 10th, 2009
5,569
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.41 KB | None | 0 0
  1. public class Primitives {
  2.     public static char max(char[] values) {
  3.         char max = Character.MIN_VALUE;
  4.         for(char value : values) {
  5.             if(value > max)
  6.                 max = value;
  7.         }
  8.         return max;
  9.     }
  10.  
  11.     public static byte max(byte[] values) {
  12.         byte max = Byte.MIN_VALUE;
  13.         for(byte value : values) {
  14.             if(value > max)
  15.                 max = value;
  16.         }
  17.         return max;
  18.     }
  19.  
  20.     public static short max(short[] values) {
  21.         short max = Short.MIN_VALUE;
  22.         for(short value : values) {
  23.             if(value > max)
  24.                 max = value;
  25.         }
  26.         return max;
  27.     }
  28.  
  29.     public static int max(int[] values) {
  30.         int max = Integer.MIN_VALUE;
  31.         for(int value : values) {
  32.             if(value > max)
  33.                 max = value;
  34.         }
  35.         return max;
  36.     }
  37.  
  38.     public static long max(long[] values) {
  39.         long max = Long.MIN_VALUE;
  40.         for(long value : values) {
  41.             if(value > max)
  42.                 max = value;
  43.         }
  44.         return max;
  45.     }
  46.  
  47.     public static char maxChar(char... values) {
  48.         return max(values);
  49.     }
  50.  
  51.     public static byte maxByte(byte... values) {
  52.         return max(values);
  53.     }
  54.  
  55.     public static short maxShort(short... values) {
  56.         return max(values);
  57.     }
  58.  
  59.     public static int maxInt(int... values) {
  60.         return max(values);
  61.     }
  62.  
  63.     public static long maxLong(long... values) {
  64.         return max(values);
  65.     }
  66.  
  67.     public static char min(char[] values) {
  68.         char min = Character.MAX_VALUE;
  69.         for(char value : values) {
  70.             if(value < min)
  71.                 min = value;
  72.         }
  73.         return min;
  74.     }
  75.  
  76.     public static byte min(byte[] values) {
  77.         byte min = Byte.MAX_VALUE;
  78.         for(byte value : values) {
  79.             if(value < min)
  80.                 min = value;
  81.         }
  82.         return min;
  83.     }
  84.  
  85.     public static short min(short[] values) {
  86.         short min = Short.MAX_VALUE;
  87.         for(short value : values) {
  88.             if(value < min)
  89.                 min = value;
  90.         }
  91.         return min;
  92.     }
  93.  
  94.     public static int min(int[] values) {
  95.         int min = Integer.MAX_VALUE;
  96.         for(int value : values) {
  97.             if(value < min)
  98.                 min = value;
  99.         }
  100.         return min;
  101.     }
  102.  
  103.     public static long min(long[] values) {
  104.         long min = Long.MAX_VALUE;
  105.         for(long value : values) {
  106.             if(value < min)
  107.                 min = value;
  108.         }
  109.         return min;
  110.     }
  111.  
  112.     public static char minChar(char... values) {
  113.         return min(values);
  114.     }
  115.  
  116.     public static byte minByte(byte... values) {
  117.         return min(values);
  118.     }
  119.  
  120.     public static short minShort(short... values) {
  121.         return min(values);
  122.     }
  123.  
  124.     public static int minInt(int... values) {
  125.         return min(values);
  126.     }
  127.  
  128.     public static long minLong(long... values) {
  129.         return min(values);
  130.     }
  131. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement