Java Math.incrementExact() methodThe java.lang.Math.incrementExact() returns the argument incremented by one. It will throw an exception if the result overflows either int or long. SyntaxParameterReturn
Example 1Test it NowOutput: 675 Example 2Test it NowOutput: -52 Example 3Test it NowOutput: Exception in thread "main" java.lang.ArithmeticException: integer overflow at java.lang.Math.incrementExact(Math.java:909) at incrementExactExample3.main(incrementExactExample3.java:7) Example 4Test it NowOutput: Exception in thread "main" java.lang.ArithmeticException: long overflow at java.lang.Math.incrementExact(Math.java:926) at incrementExactExample4.main(incrementExactExample4.java:7) Next TopicJava Math |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India