StringTokenizer hasMoreElements() Method in Java with Examples Last Updated : 28 Jan, 2019 Comments Improve Suggest changes Like Article Like Report 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 hasMoreElements() Parameters: The method does not take any parameters. Return Value: The method returns boolean True if the availability of at least one more token is found in the string after the current position else false. Below programs illustrate the working of hasMoreElements() Method of StringTokenizer: Example 1: Java // Java code to illustrate hasMoreElements() 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"); // Counting the tokens System.out.println("The number of Tokens are: " + str_arr.countTokens()); // Checking for any tokens System.out.println(str_arr.hasMoreElements()); // Checking and displaying the Tokens while (str_arr.hasMoreElements()) { System.out.println("The Next token: " + str_arr.nextToken()); } } } Output: The number of Tokens are: 4 true The Next token: Lets The Next token: practice The Next token: at The Next token: GeeksforGeeks Example 2: Java // Java code to illustrate hasMoreElements() method import java.util.*; public class StringTokenizer_Demo { public static void main(String args[]) { // Creating a StringTokenizer StringTokenizer str_arr = new StringTokenizer(""); // Counting the tokens System.out.println("The number of Tokens are: " + str_arr.countTokens()); // Checking for any tokens System.out.println(str_arr.hasMoreElements()); } } Output: The number of Tokens are: 0 false Comment More infoAdvertise with us Next Article StringTokenizer hasMoreElements() Method in Java with Examples chinmoy lenka Follow Improve Article Tags : Misc Java Java - util package Java-Functions Java-StringTokenizer +1 More Practice Tags : JavaMisc Similar Reads 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 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 Enumeration hasMoreElements() Method in Java with Examples An object that implements the Enumeration interface generates a series of elements, one at a time. hasMoreElements() method of Enumeration used to tests if this enumeration contains more elements. If enumeration contains more element then it will return true else false. Syntax: boolean hasMoreElemen 2 min read StringTokenizer nextElement() Method in Java with Examples 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 2 min read StringTokenizer countTokens() Method in Java with Examples The countTokens() method of StringTokenizer class calculate the number of times that this tokenizer's nextToken method can be called before the method generates any further exception. Note: The current position is not advanced during the process. Syntax: public int countTokens() Parameters: The meth 2 min read Java String isEmpty() Method with Example In Java, the String isEmpty() method checks if a string is empty (length is zero). This method returns true if the string is empty and false otherwise. It is useful for validating strings in our applications.In this article, we will learn how to use the isEmpty() method in Java along with examples t 3 min read StringBuilder indexOf() method in Java with Examples In StringBuilder class, there are two types of indexOf() method depending upon the parameters passed to it. indexOf(String str) The indexOf(String str) method of StringBuilder class is the inbuilt method used to return the index within the String for first occurrence of passed substring as parameter 4 min read Java StringUtils.isNoneBlank() Method with Examples The StringUtils.isNoneBlank() is a method provided by the Apache Commons Lang library for string manipulation in Java. It is used to check if any of the given strings are not blank or empty. The StringUtils.isNoneBlank() function is part of the Apache Commons Lang library, which provides utility met 3 min read StringCharacterIterator getEndIndex() method in Java with Examples The getEndIndex() method of java.text.StringCharacterIterator class in Java is used to get the index at the ending that is to be read by this StringCharacterIterator. This method returns that index number. Syntax: public int getEndIndex() Parameter: This method do not accept any parameter. Return Va 1 min read StringCharacterIterator getIndex() method in Java with Examples The getIndex() method of java.text.StringCharacterIterator class in Java is used to get the current index that is to be read by this StringCharacterIterator. This method returns that index number. Syntax: public int getIndex() Parameter: This method do not accept any parameter. Return Value: This me 1 min read Like