What is a Short Data Type ?
In Java, the
which can hold any value between - 32,768 (-215) and 32,767 (215-1).
The primitive type
short num1 = 3;
Short num2 = 4;
Short total = (short)(num1 + num2);
short valueOfNum2 = (short)(total - num1);
The default value of a primitive
We will learn more about the wrapper class
- We can use an
short data type to store a String - We can use an
short data type to store a Boolean value of true or false. - A
short literal value can be enclosed in single or double quotes. - A
short literal value can be a negative or a positive number with the range of -215 and 215-1.
0 Comments