Java – How to convert a double value to string ?


This content was proof-read by Grammarly. You can Try Grammary for FREE

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

%d bloggers like this: