Home » Core Java » util » StringTokenizer

StringTokenizer

Java StringTokenizer Example

StringTokenizer class in Java is a utility class from java.util package. It allows us to break a string into tokens. In this example, we are going to show the use of StringTokenizer class, as well as some of its basic operations. The JDK version we use to compile the source code in this example is OpenJDK 13 and the IDE ...

Read More »

StringTokenizer with specified delimiter

This is an example of how to use a StringTokenizer with a specified delimiter in order to break a String into tokens. We can use the StringTokenizer with a delimiter to break a String, using two methods: In the first method, we use the StringTokenizer(String str, String delim) constructor of StringTokenizer get a string tokenizer for the specified string and ...

Read More »

Tokenize String with StringTokenizer

In this example we shall show you how to tokenize a String with StringTokenizer. The StringTokenizer is used to break a String into tokens. To tokenize a String with StringTokenizer one should perform the following steps: Get a new StringTokenizer for a specified String, using the StringTokenizer(String str) constructor. Get the tokens of the String, using hasMoreTokens() and nextToken() API ...

Read More »

Reverse String with StringTokenizer

With this example we are going to demonstrate how to reverse a String with a StringTokenizer. The StringTokenizer is used to break a String into tokens. In short, to reverse a String with a StringTokenizer you should: Get a new StringTokenizer for a specified String, using the StringTokenizer(String str) constructor. Create a new empty String, that will be the reversed ...

Read More »

StringTokenizer Count Tokens

This is an example of how to use a StringTokenizer to count the tokens of a String. The StringTokenizer is used to break a String into tokens. Using a StringTokenizer to count the tokens of a String implies that you should: Get a new StringTokenizer for a specified String, using the StringTokenizer(String str) constructor. Invoke countTokens() API method of StringTokenizer. ...

Read More »