what is stringtolennizer with example?

Answer Posted / eva

The string tokenizer class allows an application to break a string into tokens

The set of delimiters (the characters that separate tokens) may be specified either at creation time or on a per-token basis.

An instance of StringTokenizer behaves in one of two ways, depending on whether it was created with the returnDelims flag having the value true or false:

If the flag is false, delimiter characters serve to separate tokens. A token is a maximal sequence of consecutive characters that are not delimiters.
If the flag is true, delimiter characters are themselves considered to be tokens. A token is thus either one delimiter character, or a maximal sequence of consecutive characters that are not delimiters.

Example:

StringTokenizer st = new StringTokenizer("this is a test");
while (st.hasMoreTokens()) {
System.out.println(st.nextToken());
}

prints the following output:

this
is
a
test

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is module in project?

715


What is exception handling in java?

770


What are Normalization Rules? Define Normalization?

748


How many types of memory areas are allocated by JVM in java?

784


Explain about member inner classes?

789


List the interfaces which extends collection interface?

728


What is the use of a copy constructor?

754


Can we serialize singleton class?

754


What do you mean by constant time complexity?

806


What are the differences between wait() and sleep()?

728


How java enabled high performance?

783


When should you make a function static?

718


Can we use this () and super () in a method?

717


What is the difference between class forname and new?

758


Can we have multiple public classes in a java source file?

768