How to convert other primitive data type into string?
There are times when we want to do a data conversion from other primitive data types into string expression, for instance when we want to format the screen output or simply mixing it with other string. Using a various static method String.valueOf() we can get a string value of them.
Here is the code sample:
When called with boolean argument the String.valueOf() method return "true" or "false" string depending on the boolean argument value. When called with char argument a 1 length sized string returned.
For int, long, float, double the result are the same as calling Integer.toString(), Long.toString(), Float.toString() and Double.toString() respectively.
The result of this program execution are:
b = false
c = c
i = 100
l = 100000
f = 3.4
d = 500.99