That code puts words into an array. The length field (well, it looks like a field) tells you how many words are in the array.
Be sure to
test with some extraneous spaces and leading spaces, like
and see what happens. That may lead you to the JavaDoc on
Pattern to see if you can match any number of spaces instead of just one.

let us know how it goes!