Finds minimum value of an 2-dimensional array - Android java.lang

Android examples for java.lang:array

Description

Finds minimum value of an 2-dimensional array

Demo Code


//package com.java2s;

public class Main {
    /**//w w  w. j  a  v  a2 s .  c  o m
     * Finds minimum value of an 2-dim array
     * 
     * @param in
     *            Input array
     * @param offset
     *            Offset to use for second dimension
     * @return minimum value of the offset column for this array
     */
    public static double findMin(double[][] in, int offset) {
        double out = in[0][offset];
        for (int i = 0; i < in.length; i++) {
            if (in[i][offset] < out) {
                out = in[i][offset];
            }
        }
        return out;
    }
}

Related Tutorials