
- Java.lang Package classes
- Java.lang - Home
- Java.lang - Boolean
- Java.lang - Byte
- Java.lang - Character
- Java.lang - Character.Subset
- Java.lang - Character.UnicodeBlock
- Java.lang - Class
- Java.lang - ClassLoader
- Java.lang - Compiler
- Java.lang - Double
- Java.lang - Enum
- Java.lang - Float
- Java.lang - InheritableThreadLocal
- Java.lang - Integer
- Java.lang - Long
- Java.lang - Math
- Java.lang - Number
- Java.lang - Object
- Java.lang - Package
- Java.lang - Process
- Java.lang - ProcessBuilder
- Java.lang - Runtime
- Java.lang - RuntimePermission
- Java.lang - SecurityManager
- Java.lang - Short
- Java.lang - StackTraceElement
- Java.lang - StrictMath
- Java.lang - String
- Java.lang - StringBuffer
- Java.lang - StringBuilder
- Java.lang - System
- Java.lang - Thread
- Java.lang - ThreadGroup
- Java.lang - ThreadLocal
- Java.lang - Throwable
- Java.lang - Void
- Java.lang Package extras
- Java.lang - Interfaces
- Java.lang - Errors
- Java.lang - Exceptions
- Java.lang Package Useful Resources
- Java.lang - Useful Resources
- Java.lang - Discussion
Java - Short doubleValue() Method
The Java Short doubleValue() method retrieves the equivalent double value of the given short value after a widening primitive conversion (converting smaller data type to a bigger data type). The double primitive data type is a double-precision 64-bit floating point that has a maximum value of 1.7976931348623157 x 10308 and minimum value of 4.9406564584124654 x 10-324
For example, assume we have a short value '11’. The equivalent double value of the given short value is ‘11.0’.
short s = 11 doubleValue d = 11.0 // corresponding double value
Syntax
Following is the syntax for Java Short doubleValue() method −
public double doubleValue()
Parameters
This method does not accept any parameter.
Return Value
This method returns the numeric value represented by this object after conversion to type double.
Example
Following is an example to show the usage of Java Short doubleValue() method. Here we are creating a Short object with a positive value. Thereafter, we tried to get the its double value.
import java.lang.*; public class ShortDemo { public static void main(String[] args) { // returns the double value of this Short object Short obj = new Short("87"); double d = obj.doubleValue(); System.out.println("Value = " + d); obj = new Short("90"); d = obj.doubleValue(); System.out.println("Value = " + d); } }
Output
Let us compile and run the above program, this will produce the following result −
Value = 87.0 Value = 90.0
Example
In the example given below a Short object 'obj' is created with a negative value. After that, its equivalent double value is returned by invoking the doubleValue() method on this object −
import java.lang.*; public class ShortDemo { public static void main(String[] args) { // returns the double value of this Short object Short obj = new Short("-45"); double d = obj.doubleValue(); System.out.println("Value = " + d); obj = new Short("-92"); d = obj.doubleValue(); System.out.println("Value = " + d); } }
Output
Following is an output of the above code −
Value = -45.0 Value = -92.0
Example
Following is another example of doubleValue() method of Short class by wrapping the short value in the wrapper class Short and returning the double value of the Short object −
class ShortDemo { public static void main(String[] args) { String x = "98"; Short y = new Short(x); double result = y.doubleValue(); System.out.println("Value = " + result); } }
Output
On executing the program above, the output is obtained as follows −
Value = 98.0
Example
In the following example, a short variable is created to which a value is assigned. The double value of this short value is then returned −
import java.lang.*; public class ShortDemo { public static void main(String[] args) { // create short object and assign value to it short sval = 100; Short sobj = new Short(sval); // returns double value of Short double doubleValue = sobj.doubleValue(); // printing double value System.out.println("double value of Short is = " + doubleValue); } }
Output
While executing the above code, we get the following output −
double value of Short is = 100.0