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
What is a lock or purpose of locks in java?
What is use of valueof () in java?
What is the difference between state-based unit testing and interaction-based unit testing?
What are advantages of using Java?s layout managers than windowing systems?
Can we override private methods?
What is the most important feature of java? What is an interface?
What are wrapper classes in java?
Is array size fixed in java?
If a method is declared as protected, where may the method be accessed in java programming?
What is immutable in java?
Is string a data type in java?
What is the purpose of void class?
Write an algorithm program in java for the following question.. 1) S is a set of integers.X is an integer obtained by sum of two digits in S. Write logic for whether or not the X is from the S. The time of algorithm should not exceed o(n logn).
How does multithreading take place on a computer with a single cpu in java programming?
What are the differences between getting and load method?