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

  1. import java.util.*;
  2.  
  3. public class WarningLetterSet
  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.         Set LettersHome = new HashSet();
  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.         //Print out the number of letters to be sent and the recipient list
  28.         System.out.println(LettersHome.size()+" letters must be sent to: "+LettersHome);
  29.  
  30.     }//Main
  31. }//Warning Letters
  32.  
  33.  
  34.  
  35.