Number shortValue() in Java

shortValue(): This method is available in java.lang.Number class of Java.

Syntax:

short java.lang.Number.shortValue()

This method returns the value of the specified number as a short. This implementation returns the result of int Value cast to a short.

Parameters: NA

Returns: the numeric value represented by this object after conversion to type short.

Exceptions: NA

Approach

Java

public class NumbershortValue {
    public static void main(String[] args) {

        Number number = 19;
        System.out.println(number.shortValue());
    }
}

Output:

19

No comments:

Post a Comment