import java.util.*; // This example has two main purposes: // 1) it shows how you can make use of Java's template classes. // 2) it shows how you can use interfaces to allow for easy interchangeability // of data structures // Key points about Java templates // 1) They always use <> brackets // 2) The type parameters must be classes, not primitive types class search { static boolean find(Map myCollection, String key) { return myCollection.containsKey(key); } public static void main(String args[]) { int n = Integer.parseInt(args[0]); // parseInt converts String to int Map searchCollection = new HashMap(); int i; Integer dummyValue = new Integer(0); for (i = 0; i < n; i++) { searchCollection.put(args[i+1], dummyValue); } for (i = n+1; i < args.length; i++) { // %b is the formatting string for a boolean System.out.printf("%s %b\n", args[i], find(searchCollection, args[i])); } } }