Convert long values to int:
System. |
The tointExact() method converts a long value to an int, triggering an exception if the conversion leads to overflow. This prevents inaccuracies that may arise from overflow situations.
|
|
Parameter |
Description |
|
x |
Required. An integer to negate. |
|
Returns: |
“An integer value representing the contents of a long integer.” |
|
Throws: |
ArithmeticException – If the conversion operation results in overflow. |
|
Java Version: |
1.8+ |