bugl
bugl
HomeLearnPatternsPathsSearch
HomeLearnPatternsPathsSearch

Loading lesson path

Learn/Java/Java Reference
Java•Java Reference

Java Math toIntExact() Method

Flash cards

Review the key moves

1/4
Core idea

What is the main idea behind Java Math toIntExact() 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?

2Order

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

The toIntExact() method Converts a long value to an int and throws an exception if the conversion results in an overflow.
Definition and Usage
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