Convert double value to string in Java

Java 8Object Oriented ProgrammingProgramming

To convert double value to string, use the toString() method in Java. The method represents a value in string.

Let’s say the following is our double to be converted.

double doubleVal = 333.24;

Now, convert it to string.

String str = Double.toString(doubleVal);

The following is the final example.

Example

 Live Demo

public class Demo {
   public static void main(String args[]) {
      double doubleVal = 333.24;
      String str = Double.toString(doubleVal);
      System.out.println(str);
   }
}

Output

333.24
raja
Published on 11-Dec-2018 06:14:37
Advertisements