import java.util.*; import java.io.*; public class Dictionary { public static void main(String[] args) throws IOException { PrintStream output = System.out; Scanner input = new Scanner(System.in); // Type of collection Collection dictionary = new ArrayList(); final String DICT_NAME = "dictionary.txt"; Scanner dictionaryInput = new Scanner(new File(DICT_NAME)); while (dictionaryInput.hasNextLine()) { String word = dictionaryInput.nextLine().trim(); dictionary.add(word); } output.println(dictionary.size()); output.print("Enter a word to look up: "); while (input.hasNextLine()) { String word = input.nextLine().trim().toLowerCase(); if (dictionary.contains(word)) { output.printf("%s is in the dictionary%n%n", word); } else { output.printf("%s is not in the dictionary%n%n", word); } output.print("Enter a word to look up: "); } } }