Storing a string of ints and spaces into an array
Posted on 2004-08-29
Wow! I'm back after a long summer. Hope you had a nice one too. Anyways, I'm trying to refresh my memory on java. I was trying to store a string of ints and spaces into an array. After I read the data from "input.txt", I want it to print an exact copy to an "output.txt". The problem is, when I store it into an array, I want to store each INDIVIDUAL int - not the whole string.
0 _ _ 2 _ _ _ 4 _ 3 _ 1 // input string in "input.txt"; "_" represent spaces
Store to an array:
|0|_|_|2|_|_|_|4|_|3|_|1| // each integer has it's own position in array
0 1 2 3 4 5 6 7 8 9 10 11 // array length depends on the length of the string (or maybe there's a better way to do this?)
0 _ _ 2 _ _ _ 4 _ 3 _ 1
After I get this done, I want to implement the QuickSort function to sort the numbers. If I have questions on that, I'll make another Question in the Java section. Thank you in advance!!