bugl
bugl
HomeLearnPatternsPathsSearch
HomeLearnPatternsPathsSearch

Loading lesson path

Learn/Java/Java Reference
Java•Java Reference

Java Math incrementExact() Method

Flash cards

Review the key moves

1/4
Core idea

What is the main idea behind Java Math incrementExact() 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.incrementExact(12002));
3Order

Put the learning moves in the order that makes the concept easiest to apply.

The incrementExact() method returns 1 more than a specified integer and throws an exception if an overflow occurs.
Definition and Usage
Java Math incrementExact() Method

❮ Math Methods

Example

System.out.println(Math.incrementExact(12002));
System.out.println(Math.incrementExact(18));
System.out.println(Math.incrementExact(32));
System.out.println(Math.incrementExact(947));

Definition and Usage

The incrementExact() method returns 1 more 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 incrementExact(int
x )
public static long incrementExact(long
x )

Parameter Values

ParameterDescription
xRequired. An integer to increment from.

Technical Details

Returns:An int or long value representing 1 more than an integer.
Throws:ArithmeticException - If the increment causes an overflow.
Java version:1.8+

Previous

Java Math IEEEremainder() Method

Next

Java Math log() Method