the if statement is never true even if "word" and "Spelled" actually do match.
Norm Radder wrote:
the if statement is never true even if "word" and "Spelled" actually do match.
Add a print statement just before the if statement that prints out the values of the two variables being compared. Execute the code, copy the output and post it here so we can see what you are talking about.
Be sure to delimit the Strings (">"+theString +"<") so any extra spaces would be shown.
equals() should work.
Norm Radder wrote:Where are the Strings that you think should compare as equal (match) in the if statement?
there are over 400,000 words that are compared.
You need to reduce that to a few hundred for testing.
Norm Radder wrote:Why do you think the equals() method is not working?
Can you post some proof?
Rajith Pemabandu wrote:have you tried with function on the word. Further and variables are not defined in you sample code
That is the only value of word that has been posted.word is:Screen-reader
Norm Radder wrote:Can you post some output showing Strings that you think should match but were not found with the equals() method?
Nothing you have posted yet shows what you are asking about.
Note: It doesn't make sense to test a program with 400,000 items until it has been tested with just hundreds.
That is the only value of word that has been posted.word is:Screen-reader
When does the value of word change? What is it compared against after its value has changed?
Norm Radder wrote:Can you explain what the code is doing? It gets some Strings from the file: ListOfWords.txt
and some more Strings from the String: text
Then what is it supposed to do with those two sources of Strings?
If it is to check if the Strings from text are in the ListOfWords.txt file, it should load all the Strings in ListOfWords into a Set and then test if the next String from text is in that Set.
Have you ever tested the code with a small number of words so that the printout will not be over a few hundred lines? You need to do that.
Consider Paul's rocket mass heater. |