Create a function to find the second highest number in an array.
Related Pull Request:
I would like to implement a function that finds the second highest number in an array using Java's Streams API. This function should take an array of integers as input and return the second highest number.
Checklist:
[ ] Use Java Streams API to achieve this.
[ ] Handle edge cases, such as:
[ ] Arrays with fewer than two distinct numbers.
[ ] Arrays containing negative numbers.
[ ] Provide unit tests to ensure the functionality works as expected.
Example Input/Output:
Input: {5, 13, 4, 21, 13, 27, 2, 59, 59, 34}
Output: 59 (the second highest number)
Additional Notes:
Please include comments in the code to explain the logic used.
Summary:
Create a function to find the second highest number in an array.
Related Pull Request:
I would like to implement a function that finds the second highest number in an array using Java's Streams API. This function should take an array of integers as input and return the second highest number.
Checklist:
Example Input/Output:
{5, 13, 4, 21, 13, 27, 2, 59, 59, 34}
59
(the second highest number)Additional Notes: