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 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 java.math class and its methods | Set 1 Math class provides mathematical functions to perform basic numeric operations such as exponential, logarithm, square root, and trigonometric functions. cosh, sin, tan, abs, bitLength, multiply and many more. Implementations of the functions of Math class do not return bit-for-bit same results. Henc 4 min read Math floorDiv() method in Java The Math.floorDiv() is a built-in math function in Java that returns the largest (closest to negative infinity) integer value that is less than or equal to the algebraic quotient of two numbers. As floorDiv() is static, object creation is not required. The floorDiv() method performs division that ro 3 min read BigInteger xor() Method in Java Prerequisite: BigInteger Basics The xor(BigInteger val) method returns bitwise-XOR of two bigIntegers. This method returns a negative BigInteger if and only if exactly one of the current bigInteger and the bigInteger passed in parameter id negative. The xor() method of BigInteger class apply bitwise 2 min read Integer intValue() Method in Java intValue() of Integer class that is present inside java.lang package is an inbuilt method in java that returns the value of this integer as an int which is inherited from Number Class. The package view is as follows: --> java.lang Package --> Integer Class --> intValue() Method Syntax: publ 3 min read BigInteger clearBit() Method in Java Prerequisite: BigInteger BasicsThe clearBit() method returns a BigInteger which is used to clear a particular bit position in a BigInteger. The bit at index n of binary representation of BigInteger will be cleared means converted to zero. Mathematically we can say that it is used to calculate this 2 min read Like