Small Word Filter With List

Geoffrey Challen // 2021.9.0

Write a method called smallWordFilter that, given a non-null String containing words separated a single space (" "), returns all the words in the original String that are 3 characters or shorter in the same order in which they appeared in the original String, as a List<String>.

For example, given the input "Xyz is the very best cat" you would return the List<String> containing {"Xyz", "is", "the", "cat"}. We have skipped both "very" and "best" because they are longer than 3 characters.

Note that you should not add any import statements, since both java.util.List and java.util.ArrayList are already available.