FileDocCategorySizeDatePackage
Sets5.javaAPI DocExample1153Sat Sep 12 03:01:00 BST 1998None

Sets5

public class Sets5 extends Object

Fields Summary
Constructors Summary
Methods Summary
public static voidmain(java.lang.String[] args)

    Integer i1 = new Integer( 2 );
    Integer i2 = new Integer( 2 );

    HashSet set1 = new HashSet();
    System.out.println( "Using equals() to compare elements..." );
    System.out.println( "set1.add( i1 ) = " + set1.add( i1 ) );
    System.out.println( "set1.add( i1 ) = " + set1.add( i1 ) );
    System.out.println( "set1.add( i2 ) = " + set1.add( i2 ) );
    System.out.println( "set1.get( i1 ) = " + set1.get( i1 ) );
    System.out.println( "set1.get( i2 ) = " + set1.get( i2 ) );

    HashSet set2 = new HashSet( new IdenticalTo() );
    System.out.println( "Using == to compare elements..." );
    System.out.println( "set2.add( i1 ) = " + set2.add( i1 ) );
    System.out.println( "set2.add( i1 ) = " + set2.add( i1 ) );
    System.out.println( "set2.add( i2 ) = " + set2.add( i2 ) );
    System.out.println( "set2.get( i1 ) = " + set2.get( i1 ) );
    System.out.println( "set2.get( i2 ) = " + set2.get( i2 ) );