Double to String conversion Two ways to convert double to String: 1: Using valueOf() method public static String valueOf(double d) We can convert the double primitive to String by calling valueOf() method of String class. This method returns the string representation of the double argument. double var = 22.22 ; String strg = String . valueOf ( var ); 2: Using toString() method public String toString( ) : This is the another method that can be used to convert double to String. This method returns a string representation of the Double object. The primitive double value represented by this object is converted to a string. double var = 33.33 ; String str = Double . toString ( var ); Example: public class DoubleToString { public static void main ( String [] args ) { // Method 1: using valueOf() method of String class double dvar = 2 01.11 ; String strg = String . valueOf ( dvar ); System
P4PROGRAMMAR
IF YOU CAN DREAM IT. YOU CAN ACHIEVE IT.