StringTokenizer.nextElement() has the following syntax.
public Object nextElement()
In the following code shows how to use StringTokenizer.nextElement() method.
// ww w .java2 s . co m import java.util.StringTokenizer; public class Main { public static void main(String[] args) { StringTokenizer st = new StringTokenizer("tutorial from java2s.com"); // moving to next element st.nextElement(); // checking next to next element System.out.println("Next element is : " + st.nextElement()); System.out.println("Next element is : " + st.nextElement()); } }
The code above generates the following result.