StringTokenizer, while loops and return statements

Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Jul 2006
Posts: 3
Reputation: unitethenations is an unknown quantity at this point 
Solved Threads: 0
unitethenations unitethenations is offline Offline
Newbie Poster

StringTokenizer, while loops and return statements

 
0
  #1
Jul 5th, 2006
I have some questions on StringTokenizer.
I used it to break a string that has the format : "string1,string2,string3;string4,string5,string6"

first into the two strings:
  1. "string1,string2,string3"
  2. "string4,string5,string6"
and then:
  1. " String a = string1"
  2. "String b = string2"
  3. "String c = string3"

Where a = string4 in the next loop, and = string7 and so on if the loop is continued.
I used two while loops as well as StringTokenizer to carry this out.

However, I am supposed to return one of the tokens (say, string1)
as a string. When I use a return statement "return string1" the loop ends and does not process the remaining tokens (by this I mean that string1 could represent a car name, and string4's position in the string also indicates that it is another car name. When I ask for the car name, it only returns the first one instead of all, to all me to compare them.

Help please?

If you want to see the actual code that I've done I'd prefer to PM it.
Last edited by unitethenations; Jul 5th, 2006 at 2:01 am.
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 5,273
Reputation: iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold 
Solved Threads: 378
Featured Poster
iamthwee's Avatar
iamthwee iamthwee is offline Offline
Posting Expert

Re: StringTokenizer, while loops and return statements

 
0
  #2
Jul 5th, 2006
Give me the code to see.
*Voted best profile in the world*
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:




Views: 1901 | Replies: 1
Thread Tools Search this Thread



Tag cloud for Java
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC