Java short keyword example
- Details
- Written by Nam Ha Minh
- Last Updated on 20 August 2019   |   Print Email
In Java, the short keyword is used to declared a variable as a numeric type. A short value can hold a 16-bit integer number which ranges from -32,768 to 32,767. For example:
short length = 20120;
The short keyword can be used to declared return type of a method as well:
public short getLength() { return 20120; }
See all keywords in Java.
Related Topics:
Other Recommended Tutorials:
- 9 Rules about Constructors in Java
- 12 Rules and Examples About Inheritance in Java
- 12 Rules of Overriding in Java You Should Know
- 10 Java Core Best Practices Every Java Programmer Should Know
- Understand Interfaces in Java
- Understand how variables are passed in Java
- Understand encapsulation in Java
Comments