Java Guava | mean() method of IntMath Class Last Updated : 23 Jan, 2019 Summarize Comments Improve Suggest changes Share Like Article Like Report 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 // Java code to show implementation of // mean(int x, int y) method of Guava's // IntMath class import java.math.RoundingMode; import com.google.common.math.IntMath; class GFG { // Driver code public static void main(String args[]) { int x = 1542; int y = 421; // Using mean(int x, int y) // method of Guava's IntMath class int ans = 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 // Java code to show implementation of // mean(int x, int y) method of Guava's // IntMath class import java.math.RoundingMode; import com.google.common.math.IntMath; class GFG { // Driver code public static void main(String args[]) { int x = 214; int y = 154; // Using mean(int x, int y) // method of Guava's IntMath class int ans = 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 Reference : https://google.github.io/guava/releases/20.0/api/docs/com/google/common/math/IntMath.html#mean-int-int- Comment More infoAdvertise with us Next Article Java Guava | mean() method of IntMath Class B bansal_rtk_ Follow Improve Article Tags : Misc Java Java-Functions java-guava Practice Tags : JavaMisc Similar Reads Java Guava | mod() method of IntMath Class The mod(int x, int m) method of Guava's IntMath class accepts two parameters x and m and used to calculate the value of x modulus under m. Syntax : public static int mod(int x, int m) Parameters: This method accepts two parameters x and m which are of integer types and calculate x modulo m. Return V 2 min read IntMath Class | Guava | Java Introduction : IntMath is used to perform mathematical operations on Integer values. Basic standalone math functions are divided into the classes IntMath, LongMath, DoubleMath, and BigIntegerMath based on the primary numeric type involved. These classes have parallel structure, but each supports onl 3 min read LongMath Class | Guava | Java LongMath is used to perform mathematical operations on Long values. Basic standalone math functions are divided into the classes IntMath, LongMath, DoubleMath, and BigIntegerMath based on the primary numeric type involved. These classes have parallel structure, but each supports only the relevant su 3 min read java.math class and its methods | Set 1 Math class provides mathematical functions to perform basic numeric operations such as exponential, logarithm, square root, and trigonometric functions. cosh, sin, tan, abs, bitLength, multiply and many more. Implementations of the functions of Math class do not return bit-for-bit same results. Henc 4 min read Java Guava | IntMath.checkedAdd(int a, int b) method with Examples The checkedAdd(int a, int b) is a method of Guava's IntMath Class which accepts two parameters a and b, and returns their sum. Syntax: public static int checkedAdd(int a, int b) Parameters: The method accepts two int values a and b and computes their sum. Return Value: The method returns the sum of 2 min read Like