The mean(int x, int y) method of Guava’s IntMath class accepts two parameters x and y and calculates arithmetic mean of them rounded towards negative infinity. This method is overflow resilient.
Syntax :
public static int mean(int x, int y)
Parameters: This method accepts two parameters x and y which are of integer types.
Return Value : The method returns arithmetic mean of x and y, rounded towards negative infinity.
Exceptions : The method doesn’t have any exception.
Example 1 :
| // Java code to show implementation of// mean(int x, int y) method of Guava's// IntMath classimportjava.math.RoundingMode;importcom.google.common.math.IntMath; classGFG {     // Driver code    publicstaticvoidmain(String args[])    {        intx = 1542;        inty = 421;         // Using mean(int x, int y)        // method of Guava's IntMath class        intans = IntMath.mean(x, y);         // Displaying the result        System.out.println("Mean of "+ x + " and "                               + y + " is : "+ ans);    }} | 
Output :
Mean of 1542 and 421 is : 981
Example 2 :
| // Java code to show implementation of// mean(int x, int y) method of Guava's// IntMath classimportjava.math.RoundingMode;importcom.google.common.math.IntMath; classGFG {     // Driver code    publicstaticvoidmain(String args[])    {        intx = 214;        inty = 154;         // Using mean(int x, int y)        // method of Guava's IntMath class        intans = IntMath.mean(x, y);         // Displaying the result        System.out.println("Mean of "+ x + " and "                                 + y + " is : "+ ans);    }} | 
Output :
Mean of 214 and 154 is : 184

 
                                    







