//------------// Introduction to Programming Using Java: An Object-Oriented Approach//	Arnow/Weiss//------------// the search method// Chapter 10, Section 10.3, Page 390// MODIFICATIONS://    search is made static here so we can test it without creating an object//    main creates a Vector of Strings from input and then tests to see if//	each String can be found in the Vector.import java.io.*;import java.util.*;class TestSearch {	private static int search(String s) {	// Returns the index of a match to s in v					//    or -1 if there is no match		int k;	// k== the index of the next position in 			//      the vector to check.			// No match has been found in positions 			//      0 through k-1.		k = 0;		while (!(k==v.size() || s.equals(v.elementAt(k))))			k++;		// k==v.size || s.equals(v.elementAt(k))		if (k==v.size())			return -1;		else			return k;	}	public static void main(String[] a) throws Exception {		boolean fails=false;		BufferedReader f = new BufferedReader(new InputStreamReader(System.in));		v = new Vector();		String line = f.readLine();		String huge = "";		while (line != null) {			huge = huge.concat(line);			v.addElement(line);			line = f.readLine();		}		int k=0;		while (k != v.size()) {			if (search((String)v.elementAt(k))!=k) {				System.err.println("search failure");				fails = true;			}			k++;		}		if (search(huge)!=-1) {			System.err.println("search failure");			fails = true;		}		if (!fails)			System.out.println("search passes these tests");	}	static Vector v;}// Sample test input (no duplicates allowed!)// butter// mustard// ketchup// abc// x// z// antidisestablishmentarianism