| Author |
Doubts in the operation of StringTokenizer
|
dinesh Venkatesan
Ranch Hand
Joined: Oct 12, 2006
Posts: 134
|
|
Hi All, Please look at the following code: import java.util.*; public class Tester { public static void main(String[] args) { StringTokenizer st = new StringTokenizer("CustomeCare.$ser$",".$ser$"); while(st.hasMoreTokens()){ System.out.println(st.nextToken()); } } } I am getting the output as: Cu tom Ca Does the "$"symbol has anything to do with the operation of tokenizing the String? Please explain. Thanks in Advance!!! dinesh.
|
 |
Ernest Friedman-Hill
author and iconoclast
Marshal
Joined: Jul 08, 2003
Posts: 24081
|
|
The second argument to StringTokenizer's constructor is a list of characters that are token separators. It's not taken as a sequence of characters together -- each individual character is a separator all by itself. Don't use StringTokenizer -- use the String.split() method.
|
[Jess in Action][AskingGoodQuestions]
|
 |
dinesh Venkatesan
Ranch Hand
Joined: Oct 12, 2006
Posts: 134
|
|
Thanks for clarification! Thank you very much!
|
 |
 |
|
|
subject: Doubts in the operation of StringTokenizer
|
|
|