short keyword in java
" short"
is a Java primitive type.
A short variable can store a 16−bit integer.
Example
short height=6;
short width=12;
The short
keyword can be used as a method parameter as below:
- public void displayHeight(short height) {
- System.out.println("Height is "+height);
- }
public void displayHeight(short height) { System.out.println("Height is "+height); }
The short
keyword can be used as a return type of a method as well:
- public short getWidth() {
- short width=12;
- return width;
- }
public short getWidth() { short width=12; return width; }