StringTokenizer problem of tokenizing
- by Mr CooL
String a ="the STRING TOKENIZER CLASS ALLOWS an APPLICATION to BREAK a STRING into TOKENS. ";
StringTokenizer st = new StringTokenizer(a);
while (st.hasMoreTokens()){
System.out.println(st.nextToken());
Given above codes, the output is following,
the
STRING TOKENIZER CLASS
ALLOWS
an
APPLICATION
to
BREAK
a
STRING
into
TOKENS.
My only question is why the "STRING TOKENIZER CLASS" has been combined into one token????????
When I try to run this code,
System.out.println("STRING TOKENIZER CLASS".contains(" "));
It printed funny result,
FALSE
It sound not logical right? I've no idea what went wrong.
I found out the reason, the space was not recognized as valid space by Java somehow. But, I don't know how it turned up to be like that from the front processing up to the code that I've posted.