Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

StringTokenizer

 
aliya sharma
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm writing this simple program where StringTokenizer takes the string and gives me the result with seperator(which is , in my case). Heres the code:

but when i run my code, Im getting ballot04,expo as my output. I want to get ballot04
expo
I thought StringTokenizer removes/ignores the seperator and gives the result??. Is there something im doing wrong???. THanks for your help

Aliya
 
Scott Dunbar
Ranch Hand
Posts: 245
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to construct your StringTokenizer with the delimeter as it defaults to the space character. Something like:

 
aliya sharma
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot Scott, it works fine now.

ALiya
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic