StringTokenizer.hasMoreElements() has the following syntax.
public boolean hasMoreElements()
In the following code shows how to use StringTokenizer.hasMoreElements() method.
//from w w w. ja va 2 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 elements while (st.hasMoreElements()){ System.out.println("Next element : " + st.nextElement()); } } }
The code above generates the following result.