Finding word count for a given string
Your approach works well but it doesn't consider punctuation, for example:
@Test
public void testWordCount(){
    String str = &quot;Hey — how are you?&quot;;

    assertEquals(4, wc.countWords(str)); // Fail
    assertEquals(4, wc.countWordsTokenizer(str)); // Fail
}

Also StringTokenizer is discouraged for new code. From the Javadoc:

StringTokenizer is a legacy class that is retained for compatibility
reasons although its use is discouraged in new code. It is recommended
that anyone seeking this functionality use the split method of
String or the java.util.regex package instead.

The split method accepts a regex as input. This is to split by non-words characters:
public int countWordsSplit(String str) {
    if (str == null || str.isEmpty()) {
        return 0;
    }
    return str.split(&quot;\\W+&quot;).length;
}

Test:
@Test
public void testWordCount(){
    String str = &quot;Hey — how are you?\t\n&quot;;

    assertEquals(4, wc.countWords(str)); // Fail
    assertEquals(4, wc.countWordsTokenizer(str)); // Fail
    assertEquals(4, wc.countWordsSplit(str)); // Pass
}

Edge cases
wc.countWordsSplit(&quot;Bill's house&quot;); // returns 3

wc.countWordsSplit(&quot;1 2&quot;); // returns 2
wc.countWords(&quot;1 2&quot;); // returns 2
wc.countWordsTokenizer(&quot;1 2&quot;); // returns 2

// Letters with accents, umlaut etc.
// Other edge cases...

Considerations
It all depends on how you define what a &quot;word&quot; is in the context of your program.
Define what a word is by making some assumptions. Then find a solution that satisfies your requirements. This approach prevents you from having an over-complicated solution that your program doesn't need.
More info here
Many thanks to @RolandIllig for the helpful comments.