CodesJava

Easy learning with example program codes

Double to string in java

Java convert double to string using valueOf() method

package com.codesjava;
 
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.codesjava;
 
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.

Please follow and like us:
error
Posted in Java   








Copyright © 2019 CodesJava DMCA.com Protection Status