home *** CD-ROM | disk | FTP | other *** search
/ ActiveX Programming Unleashed CD / AXU.iso / jgl_1_1 / jgl_1_1.exe / examples / Maps6.java < prev    next >
Encoding:
Java Source  |  1996-07-14  |  1.1 KB  |  27 lines

  1. // Copyright(c) 1996 ObjectSpace, Inc.
  2. import jgl.*;
  3.  
  4. public class Maps6
  5.   {
  6.   public static void main( String[] args )
  7.     {
  8.     Integer i1 = new Integer( 2 );
  9.     Integer i2 = new Integer( 2 );
  10.  
  11.     HashMap map1 = new HashMap();
  12.     System.out.println( "Using equals() to compare elements..." );
  13.     System.out.println( "map1.add( i1, two ) = " + map1.add( i1, "two" ) );
  14.     System.out.println( "map1.add( i1, two ) = " + map1.add( i1, "two" ) );
  15.     System.out.println( "map1.add( i2, TWO ) = " + map1.add( i2, "TWO" ) );
  16.     System.out.println( "map1.get( i1 ) = " + map1.get( i1 ) );
  17.     System.out.println( "map1.get( i2 ) = " + map1.get( i2 ) );
  18.  
  19.     HashMap map2 = new HashMap( new IdenticalTo() );
  20.     System.out.println( "Using == to compare elements..." );
  21.     System.out.println( "map2.add( i1, two ) = " + map2.add( i1, "two" ) );
  22.     System.out.println( "map2.add( i1, two ) = " + map2.add( i1, "two" ) );
  23.     System.out.println( "map2.add( i2, TWO ) = " + map2.add( i2, "TWO" ) );
  24.     System.out.println( "map2.get( i1 ) = " + map2.get( i1 ) );
  25.     System.out.println( "map2.get( i2 ) = " + map2.get( i2 ) );
  26.     }
  27.   }