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.
This is what I do have so far:
import javax.swing.JOptionPane; public class checkWord2 { public static void main(String[] args) { String[] wordArray = { "hello", "goodbye", "cat", "dog", "red", "green", "sun", "moon" }; String isOrIsNot, inputWord; inputWord = JOptionPane.showInputDialog(null, "Enter a word in all lower case:"); if (wordIsThere(inputWord, wordArray)) isOrIsNot = "is"; else isOrIsNot = "is not"; JOptionPane.showMessageDialog(null, "The word " + inputWord + " " + isOrIsNot + " on the list."); } public static boolean wordIsThere(String findMe, String[] theList) { } }