This week's giveaway is in the EJB and other Java EE Technologies forum. We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line! See this thread for details.
i was given help to create a code to count operaters such as:- '+','-', '*', '/', etc..... this works fine to count number of operaters which are a single character, but i a m having trouble counting operaters which are words such:- "if", "else", "while", ect..... i tried to modify the code counting single character operaters but i keep gettin a error.
i get the following error:
H:\qp&e\1\StringCount.java:52: cannot resolve symbol symbol : method toStringArray () location: class java.lang.String String cReadline = sReadLine.toStringArray(); ^ 1 error Finished
Hello Sukh, I'm not sure this is what you're looking for. But heres a simple program that counts the occurance of a given word (if) in a sentence. In your case, sReadLine will contain the first line as a String, right?. So, you can read the line and then pass that string into stringtokenizer instead of s, which i used.
Note, im a beginner in java but to the best of my knowledge, it should work ( i tried it and worked like a charm). i don't know how efficient is it though. But give it a go. Good Luck.