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.
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.
Joined: Apr 09, 2002
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?
Joined: Oct 13, 2005
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.