home *** CD-ROM | disk | FTP | other *** search
/ BUG 15 / BUGCD1998_06.ISO / aplic / jbuilder / jsamples.z / HashSet2.java < prev    next >
Text File  |  1997-07-30  |  1KB  |  44 lines

  1. // Copyright(c) 1996,1997 ObjectSpace, Inc.
  2.  
  3. import COM.objectspace.jgl.*;
  4.  
  5. /**
  6.  * Union, intersection, difference, symmetric difference, subset.
  7.  *
  8.  * @see COM.objectspace.jgl.HashSet
  9.  * @version 2.0.2
  10.  * @author ObjectSpace, Inc.
  11.  */
  12.  
  13. public class HashSet2
  14.   {
  15.   public static void main( String[] args )
  16.     {
  17.     HashSet set1 = new HashSet();
  18.     set1.add( "ape" );
  19.     set1.add( "cat" );
  20.     set1.add( "bat" );
  21.  
  22.     HashSet set2 = new HashSet();
  23.     set2.add( "bat" );
  24.     set2.add( "fox" );
  25.     set2.add( "ape" );
  26.     System.out.println( "set1 = " + set1 + ", set2 = " + set2 );
  27.  
  28.     HashSet set3 = set1.union( set2 );
  29.     System.out.println( "set3 = set1.union( set2 ) = " + set3 );
  30.  
  31.     HashSet set4 = set1.intersection( set2 );
  32.     System.out.println( "set4 = set1.intersection( set2 ) = " + set4 );
  33.  
  34.     HashSet set5 = set1.difference( set2 );
  35.     System.out.println( "set5 = set1.difference( set2 ) = " + set5 );
  36.  
  37.     HashSet set6 = set1.symmetricDifference( set2 );
  38.     System.out.println( "set6 = set1.symmetricDifference( set2 ) = " + set6 );
  39.  
  40.     System.out.println( "set4.subsetOf( set3 ) = " + set4.subsetOf( set3 ) );
  41.     System.out.println( "set3.subsetOf( set4 ) = " + set3.subsetOf( set4 ) );
  42.     }
  43.   }
  44.