Android examples for java.lang:array calculation
computes the maximal value of a passed array
//package com.java2s; public class Main { /**/*from w ww . ja va2s. c o m*/ * computes the maximal value of a passed array * @param _arr the array to get the maximum from * @return a double[] of size 2. the first index holds the maximum value of the passed array, * the second index holds the index where the maximum value is in the passed array */ public static double[] max(double[] _arr) { double max = Double.MIN_VALUE; double maxIdx = -1; for (int i = 0; i < _arr.length; i++) { if (_arr[i] > max) { max = _arr[i]; maxIdx = i; } } return new double[] { max, maxIdx }; } }