Short Data Type In Java

Java Short Data Type ?

It's only 2 bytes (16 bits). Like the other data types, it is signed, meaning it accepts both negative and positive values. Of the three data types covered in this lesson, it is the smallest.

Its minimum value is -32,768 and maximum value is 32,767. Its default value is 0.


The default value of a short (or int, or long) is zero. This is an important item to remember, since you can save some space and time by not having to always set the variables to a value (if you will assign values later).

Short data type can be used to save memory .

Example 1:

    short sn1 = 31000;
    short sn2 = -31000;

Example 2:

Output :

 5000

Example 3: