How does Java handle integer underflows and overflows?
Leading on from that, how would you check/test that this is occurring?
It wraps around.
e.g:
public class Test { public static void main(String[] args) { int i = Integer.MAX_VALUE; int j = Integer.MIN_VALUE; System.out.println(i+1); System.out.println(j-1); } }
prints
-2147483648 2147483647