Originally posted by Rahul Bhattacharjee:
Jaikiran Pai's way is more prefered than the way that I have mentioned.As with his code we are not creating any object ,rather using a static helper finction of String class.
Also, if the type of
i changes (for example to a long), the line of code doing the conversion will not need to change.
There's a good article on String conversion here:
http://www.yoda.arachsys.com/java/stringconv.html