//------------// Introduction to Programming Using Java: An Object-Oriented Approach//	Arnow/Weiss//------------// the getSmallest method// Chapter 10, Section 10.5, Page 403// MODIFICATIONS://    getSmallest is made static here so we can test it without creating an object//    main creates a Vector of Strings which it uses to test the methodimport java.io.*;import java.util.*;class TestGetSmallest {	// Returns the index of the smallest element in v or -1 if none exist	private static int  getSmallest(Vector  v)  {		if  (v==null  ||  v.size()==0)			return -1;		int k;		// Index of next element to examine; all elements at 				//       positions less than k have been examined already.		int small;	// Index of smallest element examined so far		k  =  1;		small  =  0;		while  (k!=v.size())  {			String current  =  (String)  v.elementAt(k);			String  smallest  =  (String)  v.elementAt(small);			if  (current.compareTo(smallest)<0)				small  =  k;			k++;		}		// k==v.size()		return small;	}	private static boolean works(Vector v, String s, int k) {		v.addElement(s);		return getSmallest(v)==k;	}	public static void main(String[] a) throws Exception {		boolean	passesTests = true;		Vector v = new Vector();		passesTests &= getSmallest(v)==-1;		passesTests &= works(v,"football",0);		passesTests &= works(v,"skiing",0);		passesTests &= works(v,"baseball",2);		passesTests &= works(v,"fencing",2);		passesTests &= works(v,"wrestling",2);		passesTests &= works(v,"archery",5);		passesTests &= works(v,"swimming",5);		if (passesTests)			System.out.println("getSmallest passes these tests");		else			System.out.println("getSmallest fails these tests");	}}