dcsimg
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


advertisement
 

Tip: Beginner's Guide to the Short Primitive

Learn more about how to get started with using the short primitive.


advertisement

WEBINAR:

On-Demand

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


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 Andreea Anghel is a senior PHP developer currently working as a primary trainer for programming teams that participate at national and international software-development contests. She consults on developing educational projects at a national level. She is a coauthor of the book "XML Technologies--XML in Java" (Albastra, ISBN 978-973-650-210-1), for which she wrote the XML portions. In addition to PHP and XML, she's interested in software architecture, web services, UML, and high-performance unit tests.
Thanks for your registration, follow us on our social networks to keep up-to-date