Home »
Java Programs »
Java Conversion Programs
Conversion from Double to String in Java
Java conversion from Double to String: Here, we are going to learn how to convert a given double value to string in Java?
Submitted by IncludeHelp, on July 15, 2019
Problem statement
Given a double value and we have to convert it into string.
Java conversion from Double to String
To convert a Double to String, we use toString() method of Double class, it accepts a double value and returns the string value.
Syntax
Double.toString(double);
Java code to convert a Double to String
//Java code to convert a double to String
public class Main {
public static void main(String args[]) {
double a = 10;
double b = 20;
//variable to store result
String result = null;
//converting double to string
result = Double.toString(a);
System.out.println("result (value of a as string) = " + result);
result = Double.toString(b);
System.out.println("result (value of b as string) = " + result);
}
}
Output
result (value of a as string) = 10.0
result (value of b as string) = 20.0
Java Conversion Programs »