Here you can find the source of minMaxAvg(int[] arr)
public static int[] minMaxAvg(int[] arr)
//package com.java2s; //License from project: Open Source License public class Main { public static int[] minMaxAvg(int[] arr) { int minIndex = 0; int minValue = arr[0]; int maxIndex = 0; int maxValue = arr[0]; int total = arr[0]; for (int i = 1; i < arr.length; i++) { if (minValue > arr[i]) { minIndex = i;// ww w. ja v a 2 s. co m minValue = arr[i]; } if (maxValue < arr[i]) { maxIndex = i; maxValue = arr[i]; } total += arr[i]; } return new int[] { minValue, minIndex, maxValue, maxIndex, total / arr.length }; } }