Java Short doubleValue()方法及示例
Short类的 java.lang.Short.doubleValue() 方法是Java中的一个内置方法,用于将Short对象的值作为双数返回。
语法
public double doubleValue()
返回类型: 它返回ShortObject的值为 double
下面是doubleValue()方法在Java中的实现。
例1 :
// Java code to demonstrate// Short doubleValue() method class GFG { public static void main(String[] args) { // Short value Short a = 17; // wrapping the Short value // in the wrapper class Short Short b = new Short(a); // doubleValue of the Short Object double output = b.doubleValue(); // printing the output System.out.println("Double value of " + a + " is : " + output); }}
输出:
Double value of 17 is : 17.0
例2 :
// Java code to demonstrate// Short doubleValue() method class GFG { public static void main(String[] args) { String value = "17"; // wrapping the Short value // in the wrapper class Short Short b = new Short(value); // doubleValue of the Short Object double output = b.doubleValue(); // printing the output System.out.println("Double value of " + b + " is : " + output); }}输出:
Double value of 17 is : 17.0
