get Max Num in varied parameters - Android java.lang

Android examples for java.lang:Integer

Description

get Max Num in varied parameters

Demo Code

import java.util.Arrays;

public class Main{

    public static int getMaxNum(int... num) {
        if (num == null || num.length == 0) {
            return -1;
        }//from ww  w .j  a v a 2s  .  co  m

        Arrays.sort(num);

        return num[num.length - 1];
    }

}

Related Tutorials