Java Guava | mean() method of IntMath Class Last Updated : 23 Jan, 2019 Comments Improve Suggest changes 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 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 Java Guava | IntMath.checkedSubtract(int a, int b) method with Examples The checkedSubtract(int a, int b) is a method of Guava's IntMath Class which accepts two parameters a and b, and returns their difference. Syntax: public static int checkedSubtract(int a, int b) Parameters: The method accepts two int values a and b and computes their difference. Return Value: The me 2 min read Java Math Class Java.lang.Math Class methods help to perform numeric operations like square, square root, cube, cube root, exponential and trigonometric operations.Declarationpublic final class Math extends Object Methods of Math Class in JavaMath class consists of methods that can perform mathematical operations a 7 min read IntSummaryStatistics getAverage() method in Java with Examples The getAverage() method of IntSummaryStatistics class in Java is used to get the average of records in this IntSummaryStatistics. Syntax: public double getAverage() Parameter: This method do not accept any value as parameter. Return Value: This method returns the average of the records in this IntSu 1 min read Integer intValue() Method in Java intValue() of Integer class that is present inside java.lang package is an inbuilt method in java that returns the value of this integer as an int which is inherited from Number Class. The package view is as follows: --> java.lang Package --> Integer Class --> intValue() Method Syntax: publ 3 min read IntSummaryStatistics getSum() method in Java with Examples The getSum() method of IntSummaryStatistics class in Java is used to get the sum of records in this IntSummaryStatistics. Syntax: public long getSum() Parameter: This method do not accept any value as parameter. Return Value: This method returns the sum of the records in this IntSummaryStatistics. P 1 min read Like