Java API Tutorial - Java StringTokenizer.nextToken()








Syntax

StringTokenizer.nextToken() has the following syntax.

public String nextToken()

Example

In the following code shows how to use StringTokenizer.nextToken() method.

//  w  ww.  j  a va2 s. c o  m

import java.util.StringTokenizer;

public class Main {
   public static void main(String[] args) {
      
      StringTokenizer st = new StringTokenizer("tutorial from java2s.com");
      
      // checking next token
      System.out.println("Next token is : " + st.nextToken());
      System.out.println("Next token is : " + st.nextToken());
      System.out.println("Next token is : " + st.nextToken());
   }    
}

The code above generates the following result.