bugl
bugl
HomeLearnPatternsPathsSearchPremium
HomeLearnPatternsPaths

Loading lesson path

Learn/Java/Java Reference
Java•Java Reference

Java Math multiplyExact() Method

❮ Math Methods

multiplyExact()

Definition and Usage

The multiplyExact() method multiplies two integers and throws an exception if the result causes an overflow. This prevents incorrect results that can occur from multiplying really large numbers.

One of the following

public static int multiplyExact(int
x , int
y )
public static long multiplyExact(long
x , long
y )

Parameter Values

ParameterDescription
xRequired. The first number to be multiplied.
yRequired. The second number to be multiplied.

Technical Details

Returns:An int or long value representing the multiplication of two numbers.
Throws:ArithmeticException - If the multiplication causes an overflow.
Java version:1.8+

Previous

Java Math min() Method

Next

Java Math negateExact() Method