StringTokenizer problem of tokenizing
Posted
by Mr CooL
on Stack Overflow
See other posts from Stack Overflow
or by Mr CooL
Published on 2010-03-22T18:11:40Z
Indexed on
2010/03/22
18:21 UTC
Read the original article
Hit count: 429
java
|stringtokenizer
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.
© Stack Overflow or respective owner