Source of SortStudents.java


  1: import java.util.Arrays;

  3: public class SortStudents {

  5:     public static void main(String[] args) {
  6:         // create list of Students
  7:         Student[] ss = new Student[]{
  8:                             new Student("Jake"),
  9:                             new Student("Angie"),
 10:                             new Student("Geety")
 11:                        };

 13:         // report original
 14:         System.out.println("\nHere is a list of Students:");
 15:         System.out.println("\t" + Arrays.toString(ss));

 17:         // sort and present sorted
 18:         Arrays.sort(ss);
 19:         System.out.println("\nHere is that same list, sorted by name:");
 20:         System.out.println("\t" + Arrays.toString(ss));
 21:         System.out.println();
 22:     }

 24: }