Java - String valueOf() Method
The Java string valueOf() method returns the string representation of the double argument.
Syntax
public static String valueOf(double d)
Parameters
d |
specify a double. |
Return Value
Returns a string representation of the double argument.
Exception
NA.
Example:
In the example below, valueOf() method returns the string representation of the given argument.
import java.lang.*; public class MyClass { public static void main(String[] args) { double x1 = 125.25; System.out.println(String.valueOf(x1)); double x2 = -125.25; System.out.println(String.valueOf(x2)); } }
The output of the above code will be:
125.25 -125.25
❮ Java.lang - String