short
In short: A primitive integer type with 16 bits — value range from -32,768 to 32,767, larger than byte, smaller than the default int.
In more detail: Barely used in practice, since int (32 bits) loses no relevant performance or memory advantage over short on modern systems, but leads to overflow problems significantly less often. Most relevant for very memory-critical data structures with many values.
In Depth
short small = 32000;
short tooBig = 40000; // compiler error: constant expression outside the value range
int normal = small + 1; // the calculation result is automatically promoted to int
short back = (short) normal; // explicit casting needed to become short againA detail that often surprises: as soon as you calculate with short values, Java automatically converts the result to int (“integer promotion”) — which is why assigning back into a short variable always needs an explicit cast. short only occupies 16 instead of 32 bits, but modern CPUs often process int values just as fast or faster, because internally they calculate in 32-bit or 64-bit registers anyway — the memory advantage only really pays off for very large arrays with millions of elements (e.g. audio sample data, which classically comes as 16-bit values).
Together with byte, int, and long, short forms the family of integer primitive types in Java, which differ exclusively in their value range and memory requirements:
| Type | Bits | Value range |
|---|---|---|
byte | 8 | -128 to 127 |
short | 16 | -32,768 to 32,767 |
int | 32 | about -2.1 billion to 2.1 billion |
long | 64 | about ±9.2 quintillion |
Why short is rare in modern APIs
Most standard Java APIs (collections, streams, most libraries) consistently work with int internally, even when short would semantically be enough — this avoids constant back-and-forth casting at API boundaries and the associated risk of errors. In practice, short is encountered almost exclusively when working with binary formats or protocols that explicitly prescribe 16-bit values (audio sample data, certain network protocol headers, interoperability with C libraries via JNI), not in ordinary application code.
Signed, no unsigned short
Unlike some other languages, Java has no unsigned short (only positive values, but a doubled positive range) — every integer type in Java is always signed. Anyone needing a pure 0-to-65535 value range (as an “unsigned short” would offer) has to either use the next-larger type int, or work with bit-mask tricks to ignore the negative range on the software side.
See also: byte, long, Type Casting