Java Math incrementExact(int x) method Last Updated : 01 May, 2018 Comments Improve Suggest changes Like Article Like Report The java.lang.Math.incrementExact() is a built-in math function in java which returns the argument incremented by one.It throws an exception if the result overflows an int.As incrementExact(int x) is static, so object creation is not required. Syntax : public static int incrementExact(int x) Parameter : x : the value to be incremented Return : This method returns the argument incremented by one. Exception : It throws ArithmeticException - if the result overflows an int Example : To show working of java.lang.Math.incrementExact() method. java // Java program to demonstrate working // of java.lang.Math.incrementExact() method import java.lang.Math; class Gfg1 { // driver code public static void main(String args[]) { int a = 0; for (int i = 0; i < 5; i++) { a = Math.incrementExact(a); System.out.println(a); } } } Output: 1 2 3 4 5 java // Java program to demonstrate working // of java.lang.Math.incrementExact() method import java.lang.Math; class Gfg2 { // driver code public static void main(String args[]) { int x = Integer.MAX_VALUE; System.out.println(Math.incrementExact(x)); } } Output: Runtime Error : Exception in thread "main" java.lang.ArithmeticException: integer overflow at java.lang.Math.incrementExact(Math.java:909) at Gfg2.main(File.java:13) Comment More infoAdvertise with us Next Article Java Math incrementExact(int x) method N Niraj_Pandey Follow Improve Article Tags : Java Mathematical DSA Java-lang package java-math +1 More Practice Tags : JavaMathematical 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 Java Math decrementExact() method 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, 2 min read Java Math addExact(int a, int b) method The java.lang.Math.addExact() is a built-in math function in java which returns the sum of its arguments. It throws an exception if the result overflows an int.As addExact(int a, int b) is static, so object creation is not required. Syntax : public static int addExact(int a, int b) Parameter : a : t 1 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 Java Math subtractExact(int a , int b) method The subtractExact() is a built-in function in Java provided by the Math class. This method returns the difference of the arguments. It throws an exception if the result overflows an int or long data type. As subtractExact() is static, so object creation is not required.This method helps detect overf 2 min read Like