[an error occurred while processing this directive]

Programming Assignment 1 - Step 4


You are almost done now. The only thing left to do is write the Test2 class. This is easy because it is almost identical to teh Test1 class. In fact, you can start off with a copy of the Test1.java file, changing the class name to Test2.

The only other changes in the class are the declaration of the array A and the Comparator comp. These lines from Test1.java should be replaced by the following in Test2.java:

    String A[] = {
	new String("This"),
	new String("is"),
	new String("a"),
	new String("test"),
	new String("of"),
	new String("the"),
	new String("VectorSorter"),
	new String("class"),
	new String("on"),
	new String("a"),
	new String("list"),
	new String("of"),
	new String("String"),
	new String("objects")
    };
and
    Comparator c = Comparators.forString();

All you are doing here is changing the type of data that you are working with and selecting an appropriate comparator. With these changes, the Test2 class can be compiled and executed. The output should be like the Test1 output except for the data.

Note: The order of data is determined by the comparator that you use. The comparator suppied for this class puts all upper-case characters before lower case characters. That is, you should expect to see the word "String" at the top of your sorted list because "S" comes before any lower-case letter. [an error occurred while processing this directive]