Java – How to convert a double value to string ?

Problem Statement

You need to convert a double value to string in your java program.

Solution

Use the toString() method defined in the Double class to convert a double value to string in java.

public class Main {

    public static void main(String[] args) {

        System.out.println("Abundantcode.com Java Tutorials");

        double input = 25;
        String output = Double.toString(input);
        System.out.println(output);

    }
}

The output of the above program is

Abundantcode.com Java Tutorials

25.0