📜  数组的最小值 java 代码示例

📅  最后修改于: 2022-03-11 14:52:12.392000             🧑  作者: Mango

代码示例3
Integer[] num = { 2, 4, 7, 5, 9 };
        // using Collections.min() to find minimum element
        // using only 1 line.
        int min1 = Collections.min(Arrays.asList(num));

        // using Collections.max() to find maximum element
        // using only 1 line.
        int max1 = Collections.max(Arrays.asList(num));
        System.out.println(min1); // 2 
        System.out.println(max1); // 9