Created
April 16, 2018 02:53
-
-
Save vple/49a4be874bf6bd23c89d3e9eca5a9405 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static String int2String(int n) { | |
if (n == 0) { | |
return "0"; | |
} | |
List<String> digits = new ArrayList<>(); | |
while (n > 0) { | |
int digit = n % 10; | |
digits.add(digit2String(digit)); | |
n = n / 10; | |
} | |
String result = ""; | |
for (int i = digits.size() - 1; i >= 0; i--) { | |
result += digits.get(i); | |
} | |
return result; | |
} | |
public static String digit2String(int digit) { | |
// Chosen implementation here... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment