I want to get the first token then the second and so on for computation. My only problem is that I don't know what action should I do if the number of tokens are not defined or unknown.
Thank you for that tip. What should be my algorithm/steps for scanner?
Stephan van Hulst
Joined: Sep 20, 2010
Obviously the format is not int, because there are characters like '*' and ':'. How should we deal with them?
Anyway, if you know how to delimit the input, then you can create a Scanner instance on the input, and set the delimiter. Then all you have to do is perform a while loop in which you check Scanner.hasNextInt() and in the body you read Scanner.nextInt().
No, it isn’t. I can see no way to get an int out of that expression, not even if : means divide. That is a String with various numbers in. It should be easy enough to work out a regular expression for, but beware ^ is a meta-character in regular expressions.