Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

need help on converting number list to array..

Status
Not open for further replies.

GoSooJJ

Programmer
Feb 24, 2001
76
US
hi all~
i'm still new to java...
i have question about list and array.
if i have this string "1,2,3,4,5,6,..." from the database, how can i store them into array. assume that we dont now how many numbers are in a string. also, can anyone show me how to do in list function.

well, i should know this but java seems like c++ to me, which i didn't like it.. ^^

Thx again.
JJ //
 
You could use the
Code:
StringTokenizer
class with , as the delimiter to pop off the individual values from the
Code:
String
. Consult JavaDocs for more information on
Code:
StringTokenizer
. As you pop off each token just
Code:
add()
it to your
Code:
Collection
. Again consult JavaDocs for more information on the
Code:
Collection
classes or any basic Java Book should have more than adequate examples on the
Code:
Collection
API.
 
Thx wushutwist!
your info was very helpful.
i will look for more info about StringTokenizer.
again, thx.
JJ //
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top