This sounds a lot like a homework assignment. We're not here to do your homework for you, we're here to help you understand Java better and help you to help yourself. So -- what have you tried already? What are your ideas about how to solve this? Tell us what you've attempted and then we'll try to help you find a better solution.
Hi Sukh Singh, I would help you out, if you could be a bit precise at explaining your problem. And also much better, with an example so as to let me know what exactly you wanted to do.
Joined: Nov 30, 2004
i am having problems in counting the operaters in a source code which has been saved as a text file. i have to set set certain operaters like "end", "if", "+", "*" etc... in arraylist and then i need to compare these operaters to the text file and see if they appear in the source code and then count how many times they appear in the source code.
Taking an input stream apart into tokens is frequently handled by a java.io.StreamTokenizer I think that is what Java compilers use since it is set up to recognize quoted strings and various comment styles. Bill
i just dont know where to start it. i know i have to create a array holding the operaters i want to count, buti dont know what to do next. i've tried to use the code, which i have shown above as a guidline to count the operaters, but i keep messing up. i am able to read from the text file, but i am unable to compare the words in the text file to the words/operaters in the array list and count them.
for example if had the following operaters in my araylist if, else, while, +, -, *, etc.... how can i count how many times each operater appears in a source code from a text file.