aspose file tools
The moose likes Beginning Java and the fly likes Split into int array Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "Split into int array" Watch "Split into int array" New topic
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
    
    6

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
    
    4
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Split into int array
 
Similar Threads
String[] : cut a Date every "/"
Strings
Naming Arrays
User input into array
splitting arrays