– Add coment to this code
static intsafeAdd(int left, int right)
{
if(right<0) {
if(left>Integer.MAX_VALUE– right) {
thrownew ArithmeticException(“Integer overflow”);
}
}
else{
if(left<Integer.MIN_VALUE– right) {
thrownew ArithmeticException(“Integer overflow”);
}
}
returnleft+ right;
}
Expert Answer
An answer will be send to you shortly. . . . .