| Author |
Split into int array
|
Rob Hunter
Ranch Hand
Joined: Apr 09, 2002
Posts: 788
|
|
|
I'm trying to pass in a string into my applet (not really an applet specific question) that is delimited by (let's say tilde ~). How can I easily split that string up and assign it to an int array? Any suggestions would be appreciated. Various approaches would be interesting to see as well. Thanks.
|
 |
fred rosenberger
lowercase baba
Bartender
Joined: Oct 02, 2003
Posts: 9948
|
|
There are several ways to split a string - did you check the API?
once you do that, you'll have an array of strings. you would then need to parse those into ints, and then stick them into your array.
What have you tried so far?
|
Never ascribe to malice that which can be adequately explained by stupidity.
|
 |
Rob Hunter
Ranch Hand
Joined: Apr 09, 2002
Posts: 788
|
|
|
Without looping is there no alternative? I was hoping to be able to somehow split and cast that String array into an int array. Is that possible?
|
 |
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32674
|
|
|
No. You can split the String[] easily; if you go through the String class, you will find methods which split easily. But each member of that array has to be parsed to an int; you can't cast or reassign it.
|
 |
 |
|
|
subject: Split into int array
|
|
|