StringTokenizer hasMoreTokens() in Java

hasMoreTokens(): This method is available in java.util.StringTokenizer class of Java.

Syntax:

java.util.StringTokenizer.hasMoreTokens()

This method tests if there are more tokens available from this tokenizer's string.

Parameters: NA

Returns: true if and only if there is at least one token in the string after the current position; false otherwise.

Exceptions: NA

Approach

Java

import java.util.StringTokenizer;

public class StringTokenizerhasMoreTokens {
    public static void main(String[] args) {
        StringTokenizer stringTokenizer =
new StringTokenizer("Hello Java Program");

        System.out.println(stringTokenizer.hasMoreTokens());
    }
}

Output:

true


No comments:

Post a Comment