Java Math negateExact() method
The java.lang.Math.negateExact() is a built-in function in Java that returns the negation of the argument, 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. Why does it Overflow?It throws an er