Google Guava is a java library with lot of utilities and reusable components. This requires the library guava-10.0.jar to be in classpath. The following example shows using Ints.min() and Ints.max() API.
package com.bethecoder.tutorials.guava.primitive_tests; import com.google.common.primitives.Ints; public class IntMinMaxTest { /** * @param args */ public static void main(String[] args) { int [] values = { 12, 1729, 6, 8, 249, 729, 1000 }; System.out.println("Max value in the array : " + Ints.max(values)); System.out.println("Min value in the array : " + Ints.min(values)); } }
Max value in the array : 1729 Min value in the array : 6