/* Author: Jacob Pavlovec Date: 11/5/07 This class was created as an example to show why a person might wish to use an interface. We create an array of song objects and then use the sort method of the Arrays class to sort the songs. In order to be sorted by the Arrays' sort method, song must implement Comparable */ //import the Arrays class, which has a method called sort, //The sort method takes an array of Comparable Objects as //an argument and sorts the items in the array. import java.util.Arrays; public class SortSongs { public static void main(String[] args) { //Create an array of song objects Song[] songs = { new Song("Take care of me Baby ", "Doe, John ", 1980), new Song("You will live on in my heart.", "Niss, Kim ", 1992), new Song("I know you are out there. ", "Winslow, Kate ", 2000), new Song("Only a few more days ", "Hoover, Herbert", 1940), new Song("An Acorn in my Shoe ", "Jones, Davey ", 2006) }; print(songs); //This method requires that the items in the array implement the // Comparable interface. Arrays.sort(songs); print(songs); } public static void print(Song[] arr) { for(int i=0;i