Home Java Java-conversion Convert Integer to Double
Questions:Ask|Latest


 
 

Share on Google+Share on Google+

Convert Integer to Double

Advertisement
In this section, you will learn to convert an integer into a double.

Convert Integer to Double 

     

In this section, you will learn to convert an integer into a double. The the java.lang package provides the functionality for converting an integer type data into a double.

Code Description:

This program helps you in converting an integer type data into a double. Define a class named "IntegerToDouble" for java component. Program takes an integer value at the console and it converts an integer type data into a double using the toString() method. This method returns a string representation of a double object. It converts a double into a string and also vice-versa.

Here is the code of this program:

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

public class IntegerToDouble {
  public static void main(String[] argsthrows IOException{
  BufferedReader buff = 
  new 
BufferedReader(new InputStreamReader(System.in))
  System.out.println("Enter the integer value:");
  String d = buff.readLine();
  String s = new Double(d).toString();  
  System.out.println("Double:=" + s);
  }
}

Download this program:

Output of  this program given below.

C:\corejava>java IntegerToDouble
Enter the integer value:
24
Double:=24.0
C:\corejava>
Advertisement

Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: July 4, 2007

Ask Questions?    Discuss: Convert Integer to Double   View All Comments

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments
kakao
April 4, 2011
kakao

integer to double? maybe string to double
DMCA.com