The **mean(long x, long y)** method of Guava’s LongMath 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 long mean(long x, long y)

**Parameters:** This method accepts two parameters x and y which are of long type.

**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(long x, long y) method of Guava's` `// LongMath class` ` ` `import` `java.math.RoundingMode;` `import` `com.google.common.math.LongMath;` ` ` `class` `GFG {` ` ` ` ` `// Driver code` ` ` `public` `static` `void` `main(String args[])` ` ` `{` ` ` `long` `x = ` `1542` `;` ` ` `long` `y = ` `421` `;` ` ` ` ` `// Using mean(long x, long y)` ` ` `// method of Guava's LongMath class` ` ` `long` `ans = LongMath.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(long x, long y) method of Guava's` `// LongMath class` ` ` `import` `java.math.RoundingMode;` `import` `com.google.common.math.LongMath;` ` ` `class` `GFG {` ` ` ` ` `// Driver code` ` ` `public` `static` `void` `main(String args[])` ` ` `{` ` ` `long` `x = ` `65` `;` ` ` `long` `y = ` `41` `;` ` ` ` ` `// Using mean(long x, long y)` ` ` `// method of Guava's LongMath class` ` ` `long` `ans = LongMath.mean(x, y);` ` ` ` ` `// Displaying the result` ` ` `System.out.println(` `"Mean of "` `+ x + ` `" and "` ` ` `+ y + ` `" is : "` `+ ans);` ` ` `}` `}` |

**Output:**

Mean of 65 and 41 is : 53

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****.**