Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: LGPL 

public class Main {
    /**
     * computes the minimal value of a passed array
     * @param _arr the array to get the minimum from
     * @return a double[] of size 2. the first index holds the minimum value of the passed array,
     * the second index holds the index where the minimum value is in the passed array
     */
    public static double[] min(double[] _arr) {
        double min = Double.MAX_VALUE;
        double minIdx = -1;

        for (int i = 0; i < _arr.length; i++) {
            if (_arr[i] < min) {
                min = _arr[i];
                minIdx = i;
            }
        }
        return new double[] { min, minIdx };
    }
}