home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1998 October A / Pcwk10a98.iso / Inprise / TRIAL / JBUILDER / JSAMPLES.Z / HashSet7.java < prev    next >
Text File  |  1998-05-08  |  1KB  |  37 lines

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