Java Short doubleValue()方法及示例

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

Python教程

Java教程

Web教程

数据库教程

图形图像教程

大数据教程

开发工具教程

计算机教程