Using the StringTokenizer class



This little java code example shows the principle of the StringTokenizer class. If you want to devide a String that has substrings divided with a separator you create a new instance of the class and send the string as the first argument and the devider as the second argument.
You loop through it by calling the hasMoreTokens() method which returns true until there are no more tokens left.
In this example we just print out each token on a new line.
The output of the example is:







Search for more Java info on this site here:
Custom Search


Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">