home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 1998 October
/
PCWorld_1998-10_cd.bin
/
software
/
prehled
/
inprise
/
JSAMPLES.Z
/
HashMap3.java
< prev
next >
Wrap
Text File
|
1998-05-08
|
1KB
|
36 lines
// Copyright(c) 1996,1997 ObjectSpace, Inc.
import com.objectspace.jgl.*;
/**
* Counting, finding, erasing.
*
* @see com.objectspace.jgl.HashMap
* @version 3.0.0
* @author ObjectSpace, Inc.
*/
public class HashMap3
{
public static void main( String[] args )
{
HashMap map = new HashMap();
map.add( "cat", "Meow" );
map.add( "ape", "Squeak" );
map.add( "dog", "Woof" );
map.add( "bat", "Squeak" );
System.out.println( map );
System.out.println( "map.count( dog ) = " + map.count( "dog" ) );
HashMapIterator i = map.find( "dog" );
if ( i.equals( map.end() ) ) // A simpler way: if ( i.atEnd() ) ...
System.out.println( "Could not find dog." );
else
System.out.println( "Found " + i.get() );
System.out.println( "map.remove( dog ) = " + map.remove( "dog" ) );
HashMapIterator j = map.find( "dog" );
if ( j.atEnd() ) // A simpler way: if ( j.equals( map.end() ) ) ...
System.out.println( "Could not find dog." );
else
System.out.println( "Found " + j.get() );
}
}