-
string tokenizer
Dear friends
can any body tell me why this code is not working. when i compile it, it gives me some errors about the array of tokenizer
Code:
//.......................Tokenizer function.............
strindex = 2;
int[] size = new int[1000];
StringTokenizer stok = new StringTokenizer(string[1000]);
for(int i= 0; i< strindex;i++)
{
stok[i] = StringTokenizer(string[i]);
size[i] = stok[i].countTokens();
}
[ArchAngel added CODE tags]
-
Firstly, it helps when you post if you post the compiler errors - it saves us having to look so hard.
In this case it's the line:
Code:
stok[i] = StringTokenizer(string[i]);
This line makes little sense for a couple of reasons:
1. 'stok' is declared as a reference variable to a StringTokenizer, not an array of StringTokenizers, so you can't reference an element on it.
2. You can't just call 'StringTokenizer(String[i])'. I'm guessing you meant to type 'new StringTokenizer(string[i]).