bugl
bugl
HomeLearnPatternsPathsSearchPremium
HomeLearnPatternsPaths

Loading lesson path

Learn/Java/Java Reference
Java•Java Reference

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