WE_ALL_LOVE_SHOUTY_SNAKE_CASE_SO_I_WROTE_A_PROGRAM_FOR_IT!!1!Alright, enough of this. This is a rags-to-riches from this question. The pattern is pretty simple, it takes a String input, verifies if it is numerical, and if so, converts it to SHOUTY_SNAKE_CASE.Example : 1231 -> ONE_TWO_THREE_ONEIt is fairly simple but it is also the first time I used the Java 8's streams, so I wanted an opinion on my (simple) use of it.private static final String[] words =         new String[]{zero,one,two,three,four,five,six,seven,eight,nine};public static String convertNumbersToWords(final String input) {    if(input == null || !input.matches(^\\d*$)){        throw new IllegalArgumentException(input cannot be null or non-numerical.);    }    return input.chars()             .mapToObj(c -> getWordFromCharCode(c).toUpperCase())             .collect(Collectors.joining(_));}private static String getWordFromCharCode(int code){    return words[code - 48];}
SHOUTY_SNAKE_CASED NUMBERS
java;rags to riches;numbers to words
Since you need an enumerated set of LOUD_WORDS that aligns with numbers, preferably as some form of numeric indices... an enum instead of String[] seems to be the perfect fit:enum Word {    ZERO, ONE, TWO, THREE, FOUR, FIVE, SIX, SEVEN, EIGHT, NINE;}(I think you can figure out the derivation.)edit: Just one note about using Word.values() as pointed out in @Simon's comments: it creates a new array each time and this may not be desirable, performance-wise.Since you're also experimenting with some of the Java 8 features, you may want to consider using an Optional too, to eliminate the if-validation:private static final String NUMBERS_ONLY = ^\\d+$;// UsageOptional.ofNullable(input)        .filter(v -> v != null && v.matches(NUMBERS_ONLY))        .orElseThrow(IllegalArgumentException::new)        .chars()        // ...If you prefer to throw NullPointerException for null values, you can stick with Optional.of(T).