Java Byte doubleValue()方法及示例

来源:这里教程网 时间:2026-02-17 20:39:57 作者:

Java Byte doubleValue()方法及示例

Byte类的 doubleValue() 方法是Java中的一个内置方法,用于将该Byte对象的值返回为双倍。

语法

ByteObject.doubleValue()

返回类型: 它返回ByteObject的值为double。

下面是doubleValue()方法在Java中的实现。

例1 :

// Java code to demonstrate// Byte doubleValue() method  class GFG {    public static void main(String[] args)    {          // byte value        byte a = 17;          // wrapping the byte value        // in the wrapper class Byte        Byte b = new Byte(a);          // doubleValue of the Byte 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// Byte doubleValue() method  class GFG {    public static void main(String[] args)    {          String value = "17";          // wrapping the byte value        // in the wrapper class Byte        Byte b = new Byte(value);          // doubleValue of the Byte Object        double output = b.doubleValue();          // printing the output        System.out.println("Double value of "                           + b + " is : " + output);    }}

输出:

Double value of 17 is : 17.0

相关推荐