import samplelist.*; class search { // find takes a pointer to the list and a pointer to // the key for which we are searching static boolean find(LinkedList searchList, String key) { // in the body of the following loop notice that we access the fields // of objects using a "." rather than an "->" as you would in C++. for (searchList.first(); !searchList.endOfList(); searchList.next()) { // note that you must use the "equals" method to determine if two // strings are equal if (searchList.get().equals(key)) return true; } return false; } public static void main(String args[]) { int n = Integer.parseInt(args[0]); LinkedList nameList = new LinkedList(); int i; for (i = 0; i < n; i++) { // append each name to the list nameList.append(args[i+1]); } for (i = n+1; i < args.length; i++) { System.out.printf("%s %b\n", args[i], find(nameList, args[i])); } } }