Home Java Java-conversion Convert Object to Double



Convert Object to Double
Posted on: March 18, 2008 at 12:00 AM
In this section, we are going to convert an object type data into a double.

Convert Object to Double

     

In this section, we are going to convert an object type data into a double. 

Code Description:

The given program helps you in converting an object type data into a double. An object contains a data 10. Firstly, we convert into a string format then we pass into the valueOf() method. And we follow similar process to double conversion. Finally, we get the converted value into a double. 

valueOf(): This method returns a double object value and the double value represented by the parameter string (str).

Here is the code of this program:

import java.io.*;
import java.lang.*;

public class ObjectToDouble{
  public static void main (String[] args){
  Object obj = 10;
  String str = obj.toString(); double d = Double.valueOf(str).doubleValue();
  System.out.println("Double value is: = " + d);  }
}

Download of this program:

Output of this program:

C:\corejava>java ObjectToDouble
Double value is: = 10.0
C:\corejava> _

Related Tags for Convert Object to Double:
cstringstlormconversiondataprocessformscriptobjectconvertiohelpmethodformatgetversiontypeipdoublevalueintthisaiforfinalprogramtoramcontainsfinallyprocdescriptioneildesrtersisectionpeimfirstceinrmpassconvertingasmntpstrjesallmeintoobjprodosimilarsessatisirllivgofollowandarcodcodestrrtsimvascrssrocriringripthstalufinjeprocesprmindodeonogrolo


More Tutorials from this section

Ask Questions?    Discuss: Convert Object to Double  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.