| Java - Need help tokenizing and parsing String to Int..?
I need to write a segment that will take a String sequence, such as "25 3 62 19", and push each integer to a stack so I can then get an output of "19 62 3 25".I am assuming a good way to do this would be to tokenize the string with a whitespace delimiter and the parse the tokens to integers so I can push each int into the stack.. or vice versa... I know the methods that I should use to do this operation but I am getting confused on how to write the code for it.This is pretty much all I have gotten so far.. and this is only tokenizing the string.. help! Thank youArrayList tokens = new ArrayList();Scanner tokenize = new Scanner(userInput);while (tokenize.hasNext()) { tokens.add(tokenize.next());}
__________________
Powered by Yahoo!
|