Java Double shortValue() Method

The shortValue() method of Double class returns the value of this object as a short after narrowing the primitive values or by casting to type short.

Syntax:

Parameters:

NA

Override:

The shortValue() method of Double class overrides the shortValue in class Number.

Return Value:

The shortValue() method returns the double value corresponding to this Double which has been converted to type short.

Example 1

Output:

1. 1240.7458 after converted to short Value = 1240
2. -1140.728 after converted to short Value = -1140
3. 7.46587634444444E8 after converted to short Value = 1522
4. 0.746587634 after converted to short Value = 0

Example 2

Output:

Enter a number = 987654.987
1. Short value =4614
2. Long value =987654
3. Byte value =6