Skip to content

Commit 0483791

Browse files
committed
Fix
1 parent 9ff8372 commit 0483791

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/main/java/com/thealgorithms/conversions/IntegerToEnglish.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,10 @@ private static String convertToWords(int number) {
5050
} else {
5151
int tensDigit = remainder / 10;
5252
int onesDigit = remainder % 10;
53-
String tens = BASE_NUMBERS_MAP.get(tensDigit * 10);
54-
String ones = BASE_NUMBERS_MAP.get(onesDigit);
53+
String tens = BASE_NUMBERS_MAP.getOrDefault(tensDigit * 10, "");
54+
String ones = BASE_NUMBERS_MAP.getOrDefault(onesDigit, "");
5555
result.append(tens);
56-
if (!ones.isEmpty()) {
56+
if (ones != null && !ones.isEmpty()) {
5757
result.append(" ").append(ones);
5858
}
5959
}

0 commit comments

Comments
 (0)