short overflow


public class Main {
    public static void main(String[] unused) {
        short i = Short.MAX_VALUE;
        System.out.println("i=" + i++);
        System.out.println("i=" + i++);
        System.out.println("i=" + i++);
    }
}

Output:


i=32767
i=-32768
i=-32767
Home 
  Java Book 
    Runnable examples  

Data Type Short:
  1. Create Short from short value
  2. Convert Short to primitive data type
  3. Convert short to String
  4. Convert String to short primitive
  5. Min and Max values of short
  6. short overflow