Short Datatype Example Java Program

Definition

Short data type is a 16-bit signed two's complement integer. Minimum value is -32,768 (-2^15) Maximum value is 32,767 (inclusive) (2^15 -1) Short data type can also be used to save memory as byte data type. A short is 2 times smaller than an int.

Syntax

short  = ;

Short Datatype Example Program

class ShortDatatype{
	public static void main(String[] args){
		short a=-32768;
		short b=32767;
		System.out.println(""+a);
		System.out.println(""+b);
	}
}

Sample Output

Output is:
-32768
32767