Repository: TheAlgorithms/Java
File: src/main/java/com/thealgorithms/conversions/IntegerToEnglish.java (Java)

Code before:
package com.thealgorithms.conversions;

import java.util.HashMap;

public final class IntegerToEnglish {
    private static final HashMap<Integer, String> BASE_NUMBERS_MAP = new HashMap<>() {
        {
            put(0, "");
            put(1, "One");
            put(2, "Two");
            put(3, "Three");
            put(4, "Four");
            put(5, "Five");
            put(6, "Six");
            put(7, "Seven");
            put(8, "Eight");
            put(9, "Nine");
            put(10, "Ten");
            put(11, "Eleven");
            put(12, "Twelve");
            put(13, "Thirteen");
            put(14, "Fourteen");
            put(15, "Fifteen");
            put(16, "Sixteen");
            put(17, "Seventeen");
            put(18, "Eighteen");
            put(19, "Nineteen");
            put(20, "Twenty");
            put(30, "Thirty");
            put(40, "Forty");
            put(50, "Fifty");

Review comment (suggestion):
Will be better to use Map instead of HashMap to declare variable.
And use map method to create:

```
    private static final Map<Integer, String> BASE_NUMBERS_MAP = Map.of(
        0, "", 1, "One", 2, "Two", 3, "Three", 4, "Four", 5, "Five",
        6, "Six", 7, "Seven", 8, "Eight", 9, "Nine", 10, "Ten",
        11, "Eleven", 12, "Twelve", 13, "Thirteen", 14, "Fourteen",
        15, "Fifteen", 16, "Sixteen", 17, "Seventeen", 18, "Eighteen",
        19, "Nineteen", 20, "Twenty", 30, "Thirty", 40, "Forty",
        50, "Fifty", 60, "Sixty", 70, "Seventy", 80, "Eighty", 90, "Ninety", 100, "Hundred"
    );
```

Code after:
package com.thealgorithms.conversions;

import java.util.Map;

public final class IntegerToEnglish {
    private static final Map<Integer, String> BASE_NUMBERS_MAP = Map.ofEntries(Map.entry(0, ""), Map.entry(1, "One"), Map.entry(2, "Two"), Map.entry(3, "Three"), Map.entry(4, "Four"), Map.entry(5, "Five"), Map.entry(6, "Six"), Map.entry(7, "Seven"), Map.entry(8, "Eight"), Map.entry(9, "Nine"),
        Map.entry(10, "Ten"), Map.entry(11, "Eleven"), Map.entry(12, "Twelve"), Map.entry(13, "Thirteen"), Map.entry(14, "Fourteen"), Map.entry(15, "Fifteen"), Map.entry(16, "Sixteen"), Map.entry(17, "Seventeen"), Map.entry(18, "Eighteen"), Map.entry(19, "Nineteen"), Map.entry(20, "Twenty"),
        Map.entry(30, "Thirty"), Map.entry(40, "Forty"), Map.entry(50, "Fifty"), Map.entry(60, "Sixty"), Map.entry(70, "Seventy"), Map.entry(80, "Eighty"), Map.entry(90, "Ninety"), Map.entry(100, "Hundred"));

    private static final Map<Integer, String> THOUSAND_POWER_MAP = Map.ofEntries(Map.entry(1, "Thousand"), Map.entry(2, "Million"), Map.entry(3, "Billion"));

    private IntegerToEnglish() {
    }

    /**
        converts numbers < 1000 to english words
     */
    private static String convertToWords(int number) {
        int remainder = number % 100;

        String result;

        if (remainder <= 20) {
            result = BASE_NUMBERS_MAP.get(remainder);
        } else if (BASE_NUMBERS_MAP.containsKey(remainder)) {
            result = BASE_NUMBERS_MAP.get(remainder);
        } else {
            int tensDigit = remainder / 10;
            int onesDigit = remainder % 10;

            result = String.format("%s %s", BASE_NUMBERS_MAP.get(tensDigit * 10), BASE_NUMBERS_MAP.get(onesDigit));