StringTokenizer hasMoreTokens() Method in Java with Examples Last Updated : 28 Jan, 2019 Comments Improve Suggest changes Like Article Like Report 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 one more token is found in the string after the current position else false. Below programs illustrate the working of hasMoreTokens() Method of StringTokenizer: Example 1: Java // Java code to illustrate hasMoreTokens() 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.hasMoreTokens()); // Checking and displaying the Tokens while (str_arr.hasMoreTokens()) { 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 hasMoreTokens() 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.hasMoreTokens()); } } Output: The number of Tokens are: 0 false Comment More infoAdvertise with us Next Article StringTokenizer hasMoreTokens() 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 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 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 Scanner hasNextLong() method in Java with Examples The hasNextLong() method of java.util.Scanner class returns true if the next token in this scanner's input can be assumed as a Long value of the given radix. The scanner does not advance past any input. In case no radix is passed as a parameter, the function interprets the radix to be default radix 3 min read Scanner hasNextBoolean() method in Java with Examples The hasNextBoolean() method of java.util.Scanner class returns true if the next token in this scanner's input can be interpreted as a Boolean using the nextBoolean() method. The scanner does not advance past any input. Syntax: public boolean hasNextBoolean() Parameters: The function does not accepts 2 min read Scanner hasNextInt() method in Java with Examples The hasNextInt() method of java.util.Scanner class returns true if the next token in this scanner's input can be assumed as a Int value of the given radix. The scanner does not advance past any input. In case no radix is passed as a parameter, the function interprets the radix to be default radix an 3 min read Scanner hasNextDouble() method in Java with Examples The hasNextDouble() method of java.util.Scanner class returns true if the next token in this scanner's input can be interpreted as a Double using the nextDouble() method. The scanner does not advance past any input. Syntax: public Double hasNextDouble() Parameters: The function does not accepts any 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 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 StringCharacterIterator hashCode() method in Java with Examples The hashCode() method of java.text.StringCharacterIterator class in Java is used to get the hashCode value of this StringCharacterIterator. This method returns an integer representing the hashCode value. Syntax: public int hashCode() Parameter: This method do not accept any parameter. Return Value: 1 min read Scanner hasNextShort() method in Java with Examples The hasNextShort() method of java.util.Scanner class returns true if the next token in this scanner's input can be assumed as a short value of the given radix. The scanner does not advance past any input. In case no radix is passed as a parameter, the function interprets the radix to be default radi 3 min read Like