Guava’s Ints.max() returns the greatest value present in array.
public static int max(int... array)
Parameters: This method takes the array as parameter which is a nonempty array of int values.
Return Value: This method returns the value present in array that is greater than or equal to every other value in the array.
Exceptions: The method throws IllegalArgumentException if array is empty.
Below examples illustrates the Ints.max() method:
Maximum value is: 15
Example 2: To demonstrate IllegalArgumentException
Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more, please refer Complete Interview Preparation Course.