Java 中的 Byte doubleValue()方法,带示例
原文:https://www . geesforgeks . org/byte-double-value-in-Java-method-with-examples/
字节类的 doubleValue() 方法是 Java 中的一个内置方法,用来将这个 Byte 对象的值作为 double 返回。
语法
ByteObject.doubleValue()
返回类型:返回字节对象的值为双。
下面是 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);
}
}
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);
}
}
Output:
Double value of 17 is : 17.0
版权属于:月萌API www.moonapi.com,转载请注明出处