数组获取最大值

Posted wangzui1127

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了数组获取最大值相关的知识,希望对你有一定的参考价值。

数组获取最大值:

class Hello2 
    public static void main(String[] args) 
        int[] arr = 11,12,13,14,15;
        int max = getMax(arr);
        System.out.println("max =" + max);
        
    
    public static int getMax(int[] arr) 
        int max = arr[0];
        for (int i = 1;i < arr.length ;i++ )
        
            if (max < arr[i])
            
                max = arr[i];
            
        
        return max;
    

结果:

技术图片

 

以上是关于数组获取最大值的主要内容,如果未能解决你的问题,请参考以下文章

Java中数组获取最大值

获取数组最大值

js获取数组中最大值和最小值

获取 JSON 数组中的最大值

给定一个数组,获取其中的最大。最小值

获取多维数组中的最大值[重复]