A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Java in General
Joined: Sep 26, 2005
Sep 29, 2005 06:58:00
I have the StringTokenizer class.I create an StringTokenizer object.This is what i do.
StringTokenizer s1=new StringTokenizer(s,",");
It should give me 5tokens.But it is giving me only 1.
,,, should be treated as null rite.
Joined: Apr 14, 2004
Sep 29, 2005 07:19:00
No, that will give you two tokens ("a" and "b").
Joined: Sep 28, 2005
Sep 29, 2005 07:25:00
If you're JDK version is >1.4 it's better to use String's split method :
"a,,,,b".split(",") will return an array of 5 String objs.
[ September 29, 2005: Message edited by: Seb Mathe ]
Regards,<br />Seb<br /> <br />SCJP 1.4
please clarify this.
Reversing a string
Searching Strings in a textfile
StringTokenizer not helping in splitting
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2014