Java array find the max and min value via sorting
import java.util.Arrays; public class Main { public static void main(String[] args) { int[] a = new int[]{1231,2,4321,112,3215,7123,3321,1234}; System.out.println(Arrays.toString(a)); Arrays.sort(a);//from ww w. ja v a 2s . c om System.out.println(Arrays.toString(a)); int min = a[0]; System.out.println("The minmum value is " + min); int max = a[a.length - 1]; System.out.println("The maxemum value is " + max); } }