Double to string in java

Java convert double to string using valueOf() method

package com.w3schools;

public class DouleToString {
  public static void main(String args[]){
      double var = 551.101;
      String str = Double.toString(var);
      System.out.println("String is: "+str);
  }
}

Output:

String is: 551.101

Download this example.

Java convert double to string using toString() method

package com.w3schools;

public class DouleToString {
  public static void main(String args[]){
      double var = 551.101;
      String str = String.valueOf(var);
      System.out.println("String is: "+str);
  }
}

Output:

String is: 551.101

Download this example.