Java as a whole is a language that generally requires a lot of coding to execute specific tasks. Hence, having shorthand for several utilities can be beneficial. One such utility, to find maximum and minimum element in array is explained in this article using “aslist()“. aslist() type casts a list from the array passed in its argument. This function is defined in “Java.utils.Arrays“.
To get the minimum or maximum value from the array we can use the Collections.min() and Collections.max() methods.
But as this method requires a list type of data we need to convert the array to list first using above explained “aslist()” function.
Minimum number of array is : 2 Maximum number of array is : 9
This article is contributed by Astha Tyagi. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
Attention reader! Don’t stop learning now. Get hold of all the important Java and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready.
- BigInteger max() and min() Methods in Java
- Min and Max in a List in Java
- How to find max memory, free memory and total memory in Java?
- Java Math max() method with Examples
- Stream.max() method in Java with Examples
- IntStream max() in Java with examples
- Collections max() method in Java with Examples
- DoubleStream max() in Java with examples
- LongStream max() in Java with examples
- BigDecimal max() Method in Java
- StrictMath max() Method in Java With Examples
- Ints max() function | Guava | Java
- Max Heap in Java
- Java Guava | Shorts.max() method with Examples
- Java Guava | Longs.max() method with Examples
- Java Guava | Doubles.max() method with Examples
- Java Guava | Chars.max() method with Examples
- Java Guava | Floats.max() method with Examples
- Java Math min() method with Examples
- Collections min() method in Java with Examples
Improved By : Johnpk