Java program to convert double type variables to string
www.igiftdiea.com
Here's a Java program to convert a double type variable to a String:
public class Main {
public static void main(String[] args) {
double d = 10.5;
String s = Double.toString(d);
System.out.println("Double value: " + d);
System.out.println("String value: " + s);
}
}
In this program, we first initialize a double variable d with the value 10.5. We then use the Double.toString method to convert d to a String and assign the result to a String variable s.
Finally, we print out the original double value and the converted String value.
The output of this program will be:
Double value: 10.5 String value: 10.5
Note that the Double.toString method returns a String representation of the double value. If you need more control over the format of the String representation, you can use the String.format method instead.
