Increase various numbers.
System. |
The incrementExact() method increments a specified integer by 1 and throws an exception in case of overflow, ensuring accurate results.
One of the following:
public static int incrementExact(int x)
|
public static long incrementExact(long x |
Parameter |
Description |
x |
Necessary: An integer to increment. |
Returns: |
An int or long value representing an integer incremented by one. |
Throws: |
ArithmeticException – Thrown if the increment results in an overflow. |
Java Version: |
1.8+ |