ni lagi nyoba string tokenizer...
aku ada methods spt ini ..
int getNumWordInASentence()//String varString
{
String varString = "ini adalah testing. gitu loh";
StringTokenizer st = new StringTokenizer(varString);
System.out.println(st.countTokens());
while (st.hasMoreTokens())
{
System.out.println(st.nextToken());
}
System.out.println(st.countTokens());
return st.countTokens();
}
ternyata kalo nextToken dijalanin .. jumlah token akan berkurang .. ni aku coba sebelum n sesudah .. hasil countTokens nggak sami .. so bcareful when you used nextToken n countTokens.
aku ada methods spt ini ..
Wednesday, October 22, 2008
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment