Java tutorial
//package com.java2s; //License from project: LGPL public class Main { /** * 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 }; } }