Hackerrank Java Int to String Solution

Hackerrank Java Int to String Solution

You are given an integer , you have to convert it into a string.

Please complete the partially completed code in the editor. If your code successfully converts  into a string  the code will print "Good job". Otherwise it will print "Wrong answer".

can range between  to  inclusive.

Sample Input 0100

Sample Output 0.MathJax_SVG_LineBox {display: table!important} .MathJax_SVG_LineBox span {display: table-cell!important; width: 10000em!important; min-width: 0; max-width: none; padding: 0; border: 0; margin: 0} Good job

Solution in java8

Approach 1.

   String s = ""+n;

Approach 2.

   String s = n+"";

Approach 3.

   String s = String.valueOf(n);

Subscribe to The Poor Coder | Algorithm Solutions

Don’t miss out on the latest issues. Sign up now to get access to the library of members-only issues.
[email protected]