package rebelsky.exam2; import java.io.PrintWriter; import java.util.Arrays; import java.util.Comparator; /** * A simple example of the use of Comparators. * * @author Samuel A. Rebelsky * @version 1.0 of November 2005 */ public class ComparisonExample { public static void main(String[] args) { Comparator byLength = new CompareStringsByLength(); Comparator alphabetically = new CompareStringsAlphabetically(); Orderer helper = new Orderer(); PrintWriter pen = new PrintWriter(System.out, true); pen.println("Considering the strings " + Arrays.toString(args)); pen.println("The shortest of those strings is " + "\"" + helper.smallest(args, byLength) + "\""); pen.println("The alphabetically first of those strings is " + "\"" + helper.smallest(args, alphabetically) + "\""); } // main(String[]) } // class ComparisonExample