get Max Element Position in double array - Java XML

Java examples for XML:DOM Element

Description

get Max Element Position in double array

Demo Code


//package com.java2s;

public class Main {
    public static int getMaxElementPosition(double[] data) {
        int pos = 0;
        double tmp = 0.0;
        for (int i = 0; i < data.length; i++) {
            pos = tmp > data[i] ? pos : i;
            tmp = tmp > data[i] ? tmp : data[i];
        }/*from w w w.  j a v  a 2  s. co  m*/
        return pos;
    }
}

Related Tutorials