Last updated 17. January 2021.

StringTokenizer in Java is a utility that allows you to break a string into pieces or multiple strings, called tokens.

For example, strings separated by a space and tabs are tokens. These markers are separated by a separator.

A delimiter is a group of characters that separates markers. Any character of the delimiter is considered a valid delimiter. For example, comma, semicolon and colon are restriction clauses.

By default, spaces, tabs, line breaks and carriage returns are used to separate lines. However, we can also use any other symbol to separate the markers.

Let’s take the example of the Java StringTokenizer.

Suppose we have the Hello Channel. If we define a space as a separator, this string will have the following three tokens:

  1. Hello
  2. Scientech
  3. Simply

If we put a comma as a separator after Hello, the next two tokens are on the same line:

  1. Hello

StringTokenizer was added in Java version 1.0 and is no longer part of the Java Collections Framework. It is included in the java.util package.

If you want to use StringTokenizer, you need to import the java.util package or at least the StringTokenizer class into your application.

StringTokenizer class declaration

The StringTokenizer class can be declared in the following general form:

the StringTokenizer
public class extends the
object and implements enumeration.

stringtokenizer in java examplestringtokenizer vs split javastringtokenizer trong javastringtokenizer with multiple delimitersstringtokenizer to arraystringtokenizer in java pptjava tokenize stringstringtokenizer c++

You May Also Like

How To Fix Thumbnails Not Showing In Windows 10

The Windows thumbnail function makes it easy to recognize photos and movies…

A Complete Guide On Resolving The Issue of Phone Overheating

The phone can sometimes even get hot, whether it’s during a game…

How To Fix Windows 10 File Explorer Dark Theme Not Working

When it comes to customisation options, Windows 10 offers users a considerable…

Apex Legends Crashing PC Fix 2020

Various problems can occur during gambling. If you’re playing the new royal…