The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.

How to check if a word is there?

I have a code with an array of words. The program asks the user to type in a word. The program should then search through the array and see if the word exists in the array or not. If it does exist, it will output "word is on the list." If not, then it will say "word is not on the list."

I am unsure as to how I should proceed writing the method to check the word. No clue whatsoever. Nada. If someone could guide me or provide a suggestion as to how I should proceed, that would be appreciated.

Re: How to check if a word is there?

So after reading through that and thinking... should I use an if statement? Such as if(inputWord.equals(wordArray))? But then I'd have to have some sort of loop that has it check the entire list of words...

Am I going down the right path of thinking here or do I need to be redirected?

Re: How to check if a word is there?

Does the code compile? Add a println statement in the loop to print out each word that is obtained from the array so you can see that all the values are looked at.
When it compiles without error, execute it for testing.

Compile and test freqjuently. Don't wait until it is all type in because there will be too many errors to fix. Compile often and fix the few errors before typing in more code and making more errors.