Flash cards
Review the key moves
1/4
Core idea
What is the main idea behind Java Math decrementExact() 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.
___.out.println(Math.decrementExact(12002));3Order
Put the learning moves in the order that makes the concept easiest to apply.
The decrementExact() method returns 1 less than a specified integer and throws an exception if an overflow occurs.
Definition and Usage
Java Math decrementExact() Method
❮ Math Methods
Example
System.out.println(Math.decrementExact(12002));
System.out.println(Math.decrementExact(18));
System.out.println(Math.decrementExact(32));
System.out.println(Math.decrementExact(947));Definition and Usage
The decrementExact() method returns 1 less than a specified integer and throws an exception if an overflow occurs. This prevents incorrect results that can occur from the overflow.
One of the following
public static int decrementExact(int
x )public static long decrementExact(long
x )Parameter Values
| Parameter | Description |
|---|---|
| x | Required. An integer to decrement from. |
Technical Details
| Returns: | An int or long value representing 1 less than an integer. |
|---|---|
| Throws: | ArithmeticException - If the decrement causes an overflow. |
| Java version: | 1.8+ |