Write Java program to Convert Double to String


This is a Java program that demonstrates how to convert a double value to a string using the Double.toString() method. In this program, a double variable a is initialized with the value of 100.3456756. Then, a null string variable str is declared.

The program then uses the System.out.println() method to print the value of the double variable a. Next, the Double.toString() method is called, passing in the double variable a as an argument. This method returns a string representation of the double value. The returned string is then assigned to the str variable.

Finally, the program uses the System.out.println() method to print the string representation of the double value that was stored in the str variable.

Source Code

public class DoubleToString
 {
    public static void main(String args[]) 
	{
        double a = 100.3456756;
        String str = null;
		System.out.println("Double Values : " + a);
 
        //convert double to string
        str = Double.toString(a);
        System.out.println("Double to String : " + str);
    }
}

Output

Double Values : 100.3456756
Double to String : 100.3456756