Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

max and min array number in java

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
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #max #min #array #number #java
ADD COMMENT
Topic
Name
6+1 =