Java Math decrementExact() method Last Updated : 19 Nov, 2020 Summarize Comments Improve Suggest changes Share Like Article Like Report The java.strictmath.lang.decrementExact() is a built-in function in java which returns the argument decremented by one, throwing an exception if the result overflows the specified datatype either long or int depending on which data type has been used on the method argument. Since this is decrement, the only scenario that we will be hitting an exception if the result is less than the minimum value. The minimum value can be derived from Long.MIN_VALUE or Integer.MIN_VALUE. Syntax: int decrementExact(int num) long decrementExact(long num) Parameter: The function accepts one mandatory parameter as shown above and described below: num - The parameter specifies the number which has to be decremented. Return Value: The function returns the argument decremented by one, throwing an exception if the result overflows the specified datatype either long or int depending on which data type has been used on the method argument. Examples: Input : 12 Output : 11 Input : -3 Output : -4 Program 1: Program to demonstrate the working of function Java // Java program to demonstrate working // of java.lang.Math.decrementExact() method import java.lang.Math; class Gfg1 { // driver code public static void main(String args[]) { int y = 12; System.out.println(Math.decrementExact(y)); int x = -3; System.out.println(Math.decrementExact(x)); } } Output: 11 -4 Program 2: Program to demonstrate the overflow in the function Java // Java program to demonstrate overflow // of java.lang.Math.decrementExact() method import java.lang.Math; class Gfg1 { // driver code public static void main(String args[]) { int y = Integer.MIN_VALUE; System.out.println(Math.decrementExact(y)); } } Output: Exception in thread "main" java.lang.ArithmeticException: integer overflow at java.lang.Math.decrementExact(Math.java:943) at Gfg1.main(File.java:12) Comment More infoAdvertise with us Next Article Java Math decrementExact() method G gopaldave Follow Improve Article Tags : Misc Java Java-lang package java-math Practice Tags : JavaMisc Similar Reads Java Math incrementExact() method The incrementExact() is a built-in function in Java provided by the Math class, which returns the argument incremented by one. It throws an exception if the result overflows the specified datatype, either long or int, depending on which data type has been used on the method argument.This method is h 2 min read LongAdder decrement() method in Java with Examples LongAdder class in Java creates a new adder with an initial sum of zero. The Java.LongAdder.decrement() is an inbuilt method in java that reduces the value by 1. Syntax: public void decrement() Parameters: The function does not accepts any parameter. Return value: The method do not returns any value 2 min read Deque element() method in Java The element() method of Deque Interface returns the element at the front the container. It does not deletes the element in the container. This method returns the head of the Deque. The method throws an exception when the Deque is empty. Syntax:  E element() Parameters: This method does not accepts 3 min read Deque getFirst() method in Java The getFirst() method of Deque Interface returns the first element or the head of the Deque. It does not deletes the element. It throws an exception when the Deque is empty. Syntax:  E getFirst() Parameters: This method does not accepts any parameter.Returns: This method returns the first element o 3 min read List clear() method in Java with Examples The clear() method of List interface in Java is used to remove all of the elements from the List container. This method does not deleted the List container, instead it just removes all of the elements from the List. Example:Java// Java Program to Demonstrate // List clear() import java.util.*; class 2 min read Like