2. If variable is non primitive datatype(i.e Integer,Float, Boolean....) then it has toString() method available. So here toString() is usefull.
3. The String.valueOf(Object) calls through to the toString() method of the given object (if it isn't null). Hence, if String.valueOf(int) is called, the primitive int will be auto-boxed to an Integer, and its toString() method will be called.
So Finally:
String.valueOf(i),
Integer.toString(i) and
Integer.valueOf(i).toString()
all the above stmts gives the same result.
No comments:
Post a Comment