The
checkedMultiply(int a, int b) is a method of Guava's
IntMath Class which accepts two parameters
a and
b, and returns their product.
Syntax:
public static int checkedMultiply(int a, int b)
Parameters: The method accepts two int values
a and
b and computes their product.
Return Value: The method returns the product of int values passed to it, provided it does not overflow.
Exceptions: The method checkedMultiply(int a, int b) throws
ArithmeticException if the product i.e, (a - b) overflows in signed int arithmetic.
Below examples illustrate the implementation of above method:
Example 1:
Output:
Product of 25 and 36 is: 900
Product of 150 and 667 is: 100050
Example 2: