home *** CD-ROM | disk | FTP | other *** search
Java Source | 1996-09-10 | 993 b | 36 lines |
- import java.util.Enumeration;
- import jgl.*;
-
- /**
- * Using another BinaryPredicate for matching
- * <p>
- * @see jgl.HashSet
- * @version 1.1
- * @author ObjectSpace, Inc.
- */
-
- public class HashSet7
- {
- public static void main( String[] args )
- {
- HashSet set = new HashSet( new IdenticalTo() );
- set.add( new Integer( 6 ) );
- set.add( new Integer( 1 ) );
- set.add( new Integer( 4 ) );
-
- // this WILL work because it is a seperate object than the other Integer(1)
- set.add( new Integer( 1 ) );
- System.out.println( set );
- System.out.println();
-
- System.out.println( "Add an object Integer(100)" );
- Integer tryit = new Integer(100);
- System.out.println( "add returns: " + set.add( tryit ) );
- System.out.println( "set = " + set );
- System.out.println( "Try to add the EXACT same object Integer(100)" );
- System.out.println( "add returns: " + set.add( tryit ) );
- System.out.println( "set = " + set );
- }
- }
-
-