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

Android examples for java.lang:array

Description

Finds maximum value of an 2-dimensional array

Demo Code


//package com.java2s;

public class Main {
    /**/* w w w.jav  a  2s . com*/
     * Finds maximum value of an 2-dim array
     * 
     * @param in
     *            Input array
     * @param offset
     *            Offset to use for second dimension
     * @return maximum value of the offset column for this array
     */
    public static double findMax(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