get int array Min Value - Java java.lang

Java examples for java.lang:int Array

Description

get int array Min 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(getMinValue(num));
    }// ww w  . j  a va 2  s .  c om

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

Related Tutorials