bugl
bugl
HomeLearnPatternsPathsSearchPremium
HomeLearnPatternsPaths

Loading lesson path

Learn/Java/Java Reference
Java•Java Reference

Java Math toIntExact() Method

❮ Math Methods

long

Definition and Usage

The toIntExact() method Converts a long value to an int and throws an exception if the conversion results in an overflow. This prevents incorrect results that can occur from the overflow.

Syntax

public static int toIntExact(long
x )

Parameter Values

ParameterDescription
xRequired. An integer to negate.

Technical Details

Returns:An int value representing the contents of a long integer.
Throws:ArithmeticException - If the conversion causes an overflow.
Java version:1.8+

Previous

Java Math toDegrees() Method

Next

Java Math toRadians() Method