Java Math decrementExact() Method

Facebooktwitterredditpinterestlinkedinmailby feather

The decrementExact() method of Math class returns the argument which is decremented by one, throwing an exception is the result overflows an int or long.

Syntax:

public static int decrementExact (int a)

Parameters:

The parameter ‘a’ represents the value to decrement.

Return Value:

The decrementExact () method returns the result after decrementing the value.

Throws:

The decrementExact () method throws:

ArithmeticException- if the result overflows an int or a long

 Example 1:

 Output:

Example 2:

 Output:

Example 3:

 Output:

Example 4:

 Output:

Facebooktwitterredditpinterestlinkedinmailby feather