1[1003] 2[03] 3[suggestion1] Process Exit... -------- question -------- how do i get an array of tokens ? i do not want the $ sign the token may not be there !in that case array element should be null and see the delim "$a" , it seems a is ignored ! what if i have delim of two chars or more ?? --kalpesh
Test 094, IBM WID 6.0 cert
SCJP 1.2
SCBCD 1.3 Beta
SCWCD 1.4 Beta
SCMAD Beta
SCDJWS Beta
KS
Kaspar Dahlqvist
Ranch Hand
Joined: Jun 18, 2001
Posts: 128
posted
0
Gidday! In the case of your delimiters, JAVA treats every character in your delimiter string as a separate delimiter. This means that '$' and 'a' are delimiters, but not "$a". To get rid of the $-sign in your tokens, use the second one of your StringTokenizers, eg the one without true in the constructor. Here, true means that the delimiters are also returned as tokens (as you probably noticed)... You can't have delimiters that are not chars. If you want to store the tokens, consider whether you know for sure how many tokens the string will result in. If you do, use an ordinary array of String. If you don't, you might want to use a Vector or some other dynamic storage... Hope this helps! //Kaspar
Kalpesh Soni
Ranch Hand
Joined: Jan 02, 2001
Posts: 310
posted
0
I could not know how to use String Tokenizer to get string array i used good old indexof