Home » Tip Bank » Java
  • Comment on this Article
Sep 30, 2019
  • facebook
  • twitter
  • in
  • Email

WEBINAR:

On-Demand

Building the Right Environment to Support AI, Machine Learning and Deep Learning


Watch

Beginner's Guide to the Short Primitive

A short is a 16-bit signed integer. It has a minimum value of -215 (-32,768), and a maximum value of 215 '1 (32,767)

short example = -32; 
short myShort = 1234; 
short anotherShort = 16; 
short addedShorts = (short) (myShort + anotherShort); // 1250
short subtractedShorts = (short) (myShort - anotherShort); // 1218

The maximum and minimum values of short can be found at:

short high = Short.MAX_VALUE; // high == 32767
short low = Short.MIN_VALUE; // low == -32768 

The default value of a short is 0 short defaultShort; // defaultShort == 0

Octavia Anghel
 
Submit a Tip
Browse "Java" Tips
Browse All Tips
sitepoint.com
enable-javascript.com