We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 9ff8372 commit 0483791Copy full SHA for 0483791
src/main/java/com/thealgorithms/conversions/IntegerToEnglish.java
@@ -50,10 +50,10 @@ private static String convertToWords(int number) {
50
} else {
51
int tensDigit = remainder / 10;
52
int onesDigit = remainder % 10;
53
- String tens = BASE_NUMBERS_MAP.get(tensDigit * 10);
54
- String ones = BASE_NUMBERS_MAP.get(onesDigit);
+ String tens = BASE_NUMBERS_MAP.getOrDefault(tensDigit * 10, "");
+ String ones = BASE_NUMBERS_MAP.getOrDefault(onesDigit, "");
55
result.append(tens);
56
- if (!ones.isEmpty()) {
+ if (ones != null && !ones.isEmpty()) {
57
result.append(" ").append(ones);
58
}
59
0 commit comments