Java StringTokenizer .hasMoreElements ()

Syntax

StringTokenizer.hasMoreElements() has the following syntax.

public boolean hasMoreElements()

Example

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


// w  w w  . j a v a2s.  co  m
import java.util.StringTokenizer;

public class Main {
   public static void main(String[] args) {
      
      StringTokenizer st = new StringTokenizer("tutorial from java2s.com");
      
      // checking elements
      while (st.hasMoreElements()){
          System.out.println("Next element : " + st.nextElement());    
      }
   }
}

The code above generates the following result.