home *** CD-ROM | disk | FTP | other *** search
/ Java 1.2 How-To / JavaHowTo.iso / javafile / ch11 / WarningLetterList.java < prev    next >
Encoding:
Java Source  |  1998-12-14  |  1.0 KB  |  36 lines

  1. import java.util.*;
  2.  
  3. public class WarningLetterList
  4. {
  5.     public static void main(String args[])
  6.     {
  7.         // Create the lists of failing students
  8.         String[] French = {"Amy", "Jose", "Jeremy", "Alice", "Patrick"};
  9.  
  10.         String[] Algebra = {"Alan", "Amy", "Jeremy", "Helen", "Alexi"};
  11.  
  12.         String[] History = {"Adel", "Aaron", "Amy", "James", "Alice"};
  13.  
  14.         // Create the set to hold the failing students
  15.         List LettersHome = new ArrayList();
  16.  
  17.         //Add the failing students from each class to the set
  18.         for (int i=0; i< French.length; i++)
  19.             LettersHome.add(French[i]);
  20.  
  21.         for (int j=0; j< Algebra.length; j++)
  22.             LettersHome.add(Algebra[j]);
  23.  
  24.         for (int k=0; k< History.length; k++)
  25.             LettersHome.add(History[k]);
  26.  
  27.         Collections.sort(LettersHome);
  28.  
  29.         //Print out the number of letters to be sent 
  30. // and the recipient list
  31. System.out.println(LettersHome.size()+" letters must be sent to: "+LettersHome);
  32.  
  33.     }//Main
  34. }//Warning Letters
  35.  
  36.