I wrote a code to count the number of operators and operands in a file. I was able to calculate the count of operators, but stuck at the operands. Do i need to use hasNextToken() method, or something else. Please Help this novice. Thank you, Kishore Kumar Bokkala

I can imagine a couple of different solutions - one using a StringTokenizer that would use the operators as the delimiters, and one using regular expressions. Do you have any ideas?

This approach won't work; have a look at the expression 'x+a- -b' (note the space character). Simply checking for '+' and/or '-' tokens in the sequence isn't gonna help you; are we talking three operands here? three operators and four operands in total? I think the original question has to be rephrased a bit before a reasonable answer can be given ... kind regards