Short Data Type in Java

 
The short data type represents a 16-bit signed two’s complement integer. The short data type has a minimum value of -32,768 and a maximum value of 32,767 (inclusive).

Program to declare and use Java primitive short variable.

/**
 * Program to declare and use Java primitive short variable.
 * @author javawithease
 */
public class DataTypeShortExample {	
  public static void main(String args[]){ 
	//Declare short type variables.
	short s1 = 10;
	short s2 = 20;
 
        //Print variables value.
        System.out.println("s1 Value: " + s1);
        System.out.println("s2 Value: " + s2);
 
        //Print Sum s1 and s2.
        System.out.print("Sum: ");
        System.out.println(s1 + s2);
  }
}

Output:

s1 Value: 10
s2 Value: 20
Sum: 30

Download this example.