Java Reference
In-Depth Information
double to String
Use
valueOf
:
String.valueOf(3.1415);
.
int to String
Use
valueOf
:
String.valueOf(72);
.
Double to String
(the class
Double
, not the primitive)
Double.toString(3.1415);
.
Integer to String
(the class
Integer
, not the primitive)
Integer.toString(72);
.
String concatenation will convert automatically, so
String
s =
"Temperature is "
+ 72 +
" degrees."
will result in the string
"Temperature is 72 degrees."