The String.valueOf() is an overloaded method. It can be used to convert double to String. The valueOf() is the static method of String class. The signature of valueOf() method for the double conversion is given below:
public static String valueOf(double d)
Java double to String Example: String.valueOf()
Let's see the simple code to convert double to String in java.
double d=12.3;//floating literal is double by default
String s=String.valueOf(d);
Example:
public class DoubleToStringExample1{
public static void main(String args[]){
double d=12.3;
String s=String.valueOf(d);
System.out.println(s);
}}
Output:
12.3
2) Double.toString()
The Double.toString() method also converts float to String. The toString() is the static method of Double class. The signature of toString() method is given below:
public static String toString(double d)
Java double to String Example: Double.toString()
Let's see the simple code to convert double to String in java using Double.toString() method.
double d=89.7;
String s=Double.toString(d);
Example:
public class DoubleToStringExample2{
public static void main(String args[]){
double d=89.7;
String s=Double.toString(d);
System.out.println(s);
}}
1) String.valueOf()
The String.valueOf() is an overloaded method. It can be used to convert double to String. The valueOf() is the static method of String class. The signature of valueOf() method for the double conversion is given below:
public static String valueOf(double d)
Java double to String Example: String.valueOf()
Let's see the simple code to convert double to String in java.
double d=12.3;//floating literal is double by default
String s=String.valueOf(d);
Example:
Output:
2) Double.toString()
The Double.toString() method also converts float to String. The toString() is the static method of Double class. The signature of toString() method is given below:
public static String toString(double d)
Java double to String Example: Double.toString()
Let's see the simple code to convert double to String in java using Double.toString() method.
double d=89.7;
String s=Double.toString(d);
Example:
Output: