StringTokenizer countTokens() Method in Java with Examples
The countTokens() method of StringTokenizer class calculate the number of times that this tokenizer’s nextToken method can be called before the method generates any further exception.
Note: The current position is not advanced during the process.
public int countTokens()
Parameters: The method does not take any parameters.
Return Value: The method is used to return the number of tokens remaining in the string using the current delimiter set.
Below programs illustrate the working of countTokens() Method of StringTokenizer:
Total number of Tokens: 4 token at  : Lets token at  : practice token at  : at token at  : GeeksforGeeks
Total number of Tokens: 3 token at  : Welcome token at  : to token at  : GeeksforGeeks
My Personal Notes arrow_drop_up
Please Login to comment...