StringTokenizer nextElement() Method in Java with Examples Last Updated : 29 Jan, 2019 Summarize Comments Improve Suggest changes Share Like Article Like Report The nextElement() method of StringTokenizer class is also used to return the next token one after another from this StringTokenizer. It is similar to the nextToken() method, except that the return type is Object rather than the String. Syntax: public Object nextElement() Parameters: The method does not take any parameters. Return Value: The method returns the next token present in the line of the string tokenizer. Below programs illustrate the working of nextElement() Method of StringTokenizer: Example 1: Java // Java code to illustrate nextElement() method import java.util.*; public class StringTokenizer_Demo { public static void main(String args[]) { // Creating a StringTokenizer StringTokenizer str_arr = new StringTokenizer( "Lets practice at GeeksforGeeks"); // Displaying the Tokens while (str_arr.hasMoreElements()) { System.out.println("The Next token: " + str_arr.nextElement()); } } } Output: The Next token: Lets The Next token: practice The Next token: at The Next token: GeeksforGeeks Example 2: Java // Java code to illustrate nextElement() method import java.util.*; public class StringTokenizer_Demo { public static void main(String args[]) { // Creating a StringTokenizer StringTokenizer str_arr = new StringTokenizer( "Welcome to GeeksforGeeks"); // Displaying the Tokens while (str_arr.hasMoreElements()) { System.out.println("The Next token: " + str_arr.nextElement()); } } } Output: The Next token: Welcome The Next token: to The Next token: GeeksforGeeks Comment More infoAdvertise with us Next Article StringTokenizer nextToken() Method in Java with Examples C chinmoy lenka Follow Improve Article Tags : Misc Java Java - util package Java-Functions Java-StringTokenizer +1 More Practice Tags : JavaMisc Similar Reads StringTokenizer nextToken() Method in Java with Examples The nextToken() method of StringTokenizer class is used to return the next token one after another from this StringTokenizer. Syntax: public String nextToken() Parameters: The method does not take any parameters. Return Value: The method returns the next token present in the line of the string token 1 min read StringCharacterIterator next() method in Java with Examples The next() method of java.text.StringCharacterIterator class in Java is used to get the next character that is to be read by this StringCharacterIterator. This method decrements this iterator to one index forward and returns that next character. Syntax: public char next() Parameter: This method do n 1 min read Stack setElementAt() method in Java with Example The setElementAt() method of Java Stack is used to set the component at the specified index of this vector to be the specified object. The previous component at that position is discarded. The index must be a value greater than or equal to 0 and less than the current size of the vector. Syntax: publ 2 min read Vector setElementAt() method in Java with Example The setElementAt() method of Java Vector is used to set the component at the specified index of this vector to be the specified object. The previous component at that position is discarded. The index must be a value greater than or equal to 0 and less than the current size of the vector. Syntax: pub 2 min read StringTokenizer hasMoreTokens() Method in Java with Examples The hasMoreTokens() method of StringTokenizer class checks whether there are any more tokens available with this StringTokenizer. Syntax: public boolean hasMoreTokens() Parameters: The method does not take any parameters. Return Value: The method returns boolean True if the availability of at least 2 min read StringTokenizer hasMoreElements() Method in Java with Examples The hasMoreElements() method of StringTokenizer class also checks whether there are any more tokens available with this StringTokenizer. It is similar to the hasMoreTokens(). The method exists exclusively so that the Enumeration interface of this class can be implemented. Syntax: public boolean hasM 2 min read Like