Java.lang.Byte.doubleValue() Method


Advertisements


Description

The java.lang.Byte.doubleValue() returns the value of this Byte as a double.

Declaration

Following is the declaration for java.lang.Byte.doubleValue() method

public double doubleValue()

Specified by

doubleValue in class Number

Parameters

NA

Return Value

This method returns the numeric value represented by this object after conversion to type double.

Exception

NA

Example

The following example shows the usage of lang.Byte.doubleValue() method.

package com.tutorialspoint;

import java.lang.*;

public class ByteDemo {

   public static void main(String[] args) {

      // create 2 Byte objects b1, b2
      Byte b1, b2;

      // create 2 double primitives d1, d2
      double d1, d2;

      // assign values to b1, b2
      b1 = new Byte("100");
      b2 = new Byte("-10");

      // assign double values of b1, b2 to d1, d2
      d1 = b1.doubleValue();
      d2 = b2.doubleValue();

      String str1 = "double value of Byte " + b1 + " is " + d1;
      String str2 = "double value of Byte " + b2 + " is " + d2;

      // print d1, d2 values
      System.out.println( str1 );
      System.out.println( str2 );
   }
}

Let us compile and run the above program, this will produce the following result −

double value of Byte 100 is 100.0
double value of Byte -10 is -10.0

java_lang_byte.htm

Advertisements