- Why no overflow when byte exceeds size? [closed]
- public static void main(String[] args) {
- byte b = 127;
- ++b;
- System.out.println(b);
- }
- int c = 2147483647;
- ++c;
- System.out.println(c);
- byte b = 127;
- byte oldb = b;
- b++;
- if( b < oldb ) {
- // Calamity!!! Raise an exception!
- }