// ArraySort Example // This Person class implements the Comparable // interface. This means that it has a compareTo // method that allows it to be sorted by the // Arrays.sort method. public class Person implements Comparable { private String name; private char gender; private int age; public Person(String theName, char theGender, int theAge) { name = theName; gender = theGender; age = theAge; } public String toString( ) { return "Person: " + name + " " + gender + " " + age; } // The compareTo method is required by the // Comparable interface. public int compareTo(Object other) { int otherAge = ((Person) other).age; return age - otherAge; } }