• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Regarding string tokenizer

 
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Ranchers,

I have a written a method to return me the token of a string by specifing the token as argument in the method. for example when 2 is passed as an argument it returns me the second token. When the method is passed as 0 or more than the number of tokens I am returning null. Can you please let me know if this method breaks or fails any condition.



Here if I need to get "is" I pass 2, if i need "a" I pass 3. Was wondering does this method holds for all tokens other than 0 and greater than counttokens.

Thanks in advance.

[ February 17, 2008: Message edited by: Prem Bhazee ]
[ February 17, 2008: Message edited by: Prem Bhazee ]
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I haven't worked through all the combinations, but I think basically this could be simplified to:

It's not quite equivalent, because split takes a regular expression as parameter, so not all strings can be passed into it as they are.
 
reply
    Bookmark Topic Watch Topic
  • New Topic