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

  1. // Copyright(c) 1996 ObjectSpace, Inc.
  2. import jgl.*;
  3. import java.util.Enumeration;
  4.  
  5. public class Maps3
  6.   {
  7.   public static void main( String[] args )
  8.     {
  9.     HashMap map = new HashMap( true ); // Allow duplicates.
  10.     map.add( new Pair( "Dog", "Barky" ) );
  11.     map.add( new Pair( "Cat", "Beauty" ) );
  12.     map.add( new Pair( "Cat", "Agatha" ) );
  13.     System.out.println( "map = " + map );
  14.  
  15.     System.out.println( "Enumerator through values..." );
  16.     Enumeration values = map.elements();
  17.     while( values.hasMoreElements() )
  18.       System.out.println( "  " + values.nextElement() );
  19.  
  20.     System.out.println( "Enumerate through keys..." );
  21.     Enumeration keys = map.keys();
  22.     while( keys.hasMoreElements() )
  23.       System.out.println( "  " + keys.nextElement() );
  24.     }
  25.   }