Flash cards
Review the key moves
1/4
Core idea
What is the main idea behind Java Math multiplyExact() Method?
Lesson checks
Practice each idea before moving on
Short Mimo-style checks built from this lesson's code, terms, and sequence.
1Quick choice
Which statement best captures the main point of this lesson?
2Fill blank
Complete the missing token from the example code.
___()3Order
Put the learning moves in the order that makes the concept easiest to apply.
The multiplyExact() method multiplies two integers and throws an exception if the result causes an overflow.
Definition and Usage
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
| Parameter | Description |
|---|---|
| x | Required. The first number to be multiplied. |
| y | Required. 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+ |