You are viewing a single comment's thread. Return to all comments →
You don't even need the String s = "". You can just do
String s = Integer.toString(n);
I did this!. I'll try the parser, never seen it before... Ok its constant
String s = Integer.toString(n); is showing an error
toString() used for objects
Can't you just use String s = String.valueOf(n);
Yes we can.
really smart way
Yep, this is my favorite way.
Or, String s = String.valueOf(n);
I wonder if there's any difference between static String.valueOf and static Integer.toString...
Ok, looking at the source code,
String.valueOf just calls Integer.toString, so the only difference is an extra method invocation.
Yeah! Good point. And it's only a convenience feature where we can pass any datatyped-value I guess..
It's better to use valueOf, because you will never get NPE.
Integer.toString(); Is always prefered here
That's good content. I like it much abcya