home *** CD-ROM | disk | FTP | other *** search
/ ActiveX Programming Unleashed CD / AXU.iso / jgl_1_1 / jgl_1_1.exe / examples / HashSet7.java < prev    next >
Encoding:
Java Source  |  1996-09-10  |  993 b   |  36 lines

  1. import java.util.Enumeration;
  2. import jgl.*;
  3.  
  4. /**
  5.  * Using another BinaryPredicate for matching
  6.  * <p>
  7.  * @see jgl.HashSet
  8.  * @version 1.1
  9.  * @author ObjectSpace, Inc.
  10.  */
  11.  
  12. public class HashSet7
  13.   {
  14.   public static void main( String[] args )
  15.     {
  16.     HashSet set = new HashSet( new IdenticalTo() );
  17.     set.add( new Integer( 6 ) );
  18.     set.add( new Integer( 1 ) );
  19.     set.add( new Integer( 4 ) );
  20.  
  21.     // this WILL work because it is a seperate object than the other Integer(1)
  22.     set.add( new Integer( 1 ) );
  23.     System.out.println( set );
  24.     System.out.println();
  25.  
  26.     System.out.println( "Add an object Integer(100)" );
  27.     Integer tryit = new Integer(100);
  28.     System.out.println( "add returns: " + set.add( tryit ) );
  29.     System.out.println( "set = " + set );
  30.     System.out.println( "Try to add the EXACT same object Integer(100)" );
  31.     System.out.println( "add returns: " + set.add( tryit ) );
  32.     System.out.println( "set = " + set );
  33.     }
  34.   }
  35.  
  36.