String valueOf()
In this section, you will get the detailed explanation about the
valueOf()
method of String class. We are going to use valueOf()
method of String class in Java. The description of the code is given below for the usage of the method.
Description of the code:
This method creates a new String object containing the string representation of a
double, float, short, byte, integer, long etc. As shown in the
program code below taken strings of different types as long, short, integer,
byte etc and then we have applied the valueOf() method to get a string
object. The representation is exactly the one returned by the
Double.toString(), Long.tostring(), Short.toString(),
Float.toString() method of one argument etc.
Here is the code of the program:
|
Output of the program:
C:\unique>javac strvalueOf.java C:\unique>java strvalueOf 862 228693 55 9 852.256 259873.147369222 C:\unique> |