Java Short - shortValue() Method
The java.lang.Short.shortValue() method returns the value of this Short as a short.
Syntax
public short shortValue()
Parameters
No parameter is required.
Return Value
Returns the numeric value represented by this object after conversion to type short.
Exception
NA.
Example:
In the example below, the java.lang.Short.shortValue() method returns the given Short object as a short.
import java.lang.*; public class MyClass { public static void main(String[] args) { //creating Short objects Short val1 = 25; Short val2 = -25; //printing shortValue of the Short objects System.out.println("shortValue of the val1 is: " + val1.shortValue()); System.out.println("shortValue of the val2 is: " + val2.shortValue()); } }
The output of the above code will be:
shortValue of the val1 is: 25 shortValue of the val2 is: -25
❮ Java.lang - Short