what is stringtolennizer with example?
Answers were Sorted based on User's Feedback
Answer / 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 |
Answer / shahnawaz sheikh
StringTokeniser is a utility that helps to seperate a
complex combination of string into simpler one usually
array.
Ex a string: Name$abc;EmpCode$02335;Sex$Male
can be simple broken into
Name abc
EmpCode 02335
Sex Male
NO matter how long the occurence be.
| Is This Answer Correct ? | 1 Yes | 2 No |
How do you pass by reference?
What is Exception handling in Java How do you handle run time errors please explain with an example
You can create a string object as string str = “abc”; why cant a button object be created as button bt = “abc”;? Explain
Which is illegal identifier in java?
What is == mean?
What is the purpose of finalization in java programming?
How do you sort in descending order in java using collections sort?
What are the legal operands of the instanceof operator?
Difference between method overloading and method overriding in java ?
Which programming language is most secure?
When does a class need a virtual destructor?
How do you input a string in java?