what is stringtolennizer with example?

Answers were Sorted based on User's Feedback



what is stringtolennizer with example?..

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

what is stringtolennizer with example?..

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

Post New Answer

More Core Java Interview Questions

Is it possible to use Semaphore/ Mutex in an Interrupt Handler?

0 Answers   Ciena,


What are the library functions in java?

0 Answers  


Is finalize() similar to a destructor?

0 Answers  


import java.io.*; class Demo { public static void main(String args[]) { File f=new File("1234.msg"); String arr[]=f.list(); System.out.println(arr.length); } }

3 Answers   IBM, Ramco,


How to make a non daemon thread as daemon?

0 Answers  


What is the difference between actual and formal parameters?

0 Answers  


what is bytecode? watz the difference between machine code and bytecode?

9 Answers   Oracle,


Convert Binary tree to linked list.

0 Answers   Amazon,


What method is used to compare two strings ?

4 Answers  


What is port number in java?

0 Answers  


List the different types of classloaders in java.

0 Answers  


What is difference between core java and java ee?

0 Answers  


Categories