get int Array Max Value - Java java.lang

Java examples for java.lang:int Array

Description

get int Array Max Value

Demo Code


//package com.java2s;

public class Main {
    public static void main(String[] argv) throws Exception {
        int[] num = new int[] { 34, 35, 36, 37, 37, 37, 67, 68, 69 };
        System.out.println(getMaxValue(num));
    }/*from   w ww  . ja v a 2s.  c  o m*/

    public static int getMaxValue(int[] num) {
        int result = 0;
        for (int i = 0; i < num.length; i++) {
            int currentValue = num[i];
            if (currentValue >= result) {
                result = currentValue;
            }
        }
        return result;
    }
}

Related Tutorials