Java.lang Package Classes

Java Double - toString() Method

The java.lang.Double.toString() method returns a new String object representing the specified double argument.


public static String toString(double d)


d Specify the double to be converted.

Return Value

Returns a string representation of the argument.




In the example below, the java.lang.Double.toString() method returns a String object representing the given double argument.

import java.lang.*;

public class MyClass {
  public static void main(String[] args) {
    //creating a double value
    double x = 25.2;

    //printing the double value 
    System.out.println("The double value is: " + x); 

    //creating and printing the string 
    //representation of the double value
    String x_tostring = Double.toString(x);
    System.out.println("The string value of double is: " + x_tostring);   

The output of the above code will be:

The double value is: 25.2
The string value of double is: 25.2

❮ Java.lang - Double