020-005-009
Finding Max and Min with Collections
Medium
Problem Description
Finding Max and Min with Collections
In this problem, you will create methods that take an int array, convert it to an ArrayList, and return the maximum or minimum value using Collections.max() and Collections.min().
Learning Objective: Understand how to find maximum and minimum values in a list using Collections.max() and Collections.min()
Overview
Collections.max() and Collections.min() are utility methods that return the maximum and minimum elements in a collection.
Specifications
- Create a
findMax(int[] numbers)method- Convert the int array to an ArrayList and return the max value using
Collections.max()
- Convert the int array to an ArrayList and return the max value using
- Create a
findMin(int[] numbers)method- Convert the int array to an ArrayList and return the min value using
Collections.min()
- Convert the int array to an ArrayList and return the min value using
Method Signatures
public static int findMax(int[] numbers)
public static int findMin(int[] numbers)
Examples
findMax([34, 12, 56, 7, 89, 23]) → 89
findMin([34, 12, 56, 7, 89, 23]) → 7
Ready to Try Running Code?
Log in to access the code editor and execute your solutions for this problem.
Don't have an account?
Sign Up