I'm playing with some simple java code and I found something which I cannot explain to myself. I hope some of you can explain it to me.
I have code like this :
public int sum() {
return Integer.MAX_VALUE + Integer.MAX_VALUE;
}
I wrote a test like this:
@Test
public void testSum() throws Exception {
Integer num = myclass.sum();
System.out.println(num);
}
So I'm expecting this to throw some type of exception. But the test prints -2.
Currently my jdk is 1.8.0x60.
Best regards, Petar