//------------// Introduction to Programming Using Java: An Object-Oriented Approach//	Arnow/Weiss//------------// the extremeObjects loop// Chapter 9, Section 9.6, Page 341// MODIFICATIONS://    We have placed the loop in a static private method printLongest that prints//	the longest String in a Vector that it receives as a parameter//    We have provided a main method that initializes a Vector//      of Strings an invokes the private method.import java.io.*;import java.util.*;public class Demo_extremeObjects {	private static void printLongest(Vector v) {		////////////////////////////////////////////////////////////////////		Enumeration    e = v.elements();		String  s;		String  longest = null;	// The longest String encountered so far or null					//      if no String has been encountered.		while (e.hasMoreElements()) {			s = (String) e.nextElement();			if (longest==null || s.length()>longest.length())				longest = s;		}		System.out.println("Longest String is ".concat(longest));		////////////////////////////////////////////////////////////////////	}	public static void main(String[] a) throws Exception {		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));		Vector v = new Vector();		String line = br.readLine();		while (line!=null) {			v.addElement(line);			line = br.readLine();		}		printLongest(v);	}}// Here is some sample input for this program:// April is the cruelest month.// All the world's a stage.// My only regret is that I have but one life to give my country.// Thou shallt not take a life.// I will not tailor my thoughts to suit the fashions of the moment.