Basic HTML version of Foils prepared 13 July 98

Foil 27 A Hashtable of Colors

From Java Academy II:Intermediate Java NPAC/ECS Java Academy -- February to April 98. by Tom Scavo

The ColorString Applet
1 To associate colors with their names: Hashtable colors = new Hashtable(); colors.put( "black", Color.black ); colors.put( "brown", new Color( 0xA5, 0x2A, 0x2A ) );
2 Access the hashtable as follows: c = ( Color ) colors.get( "brown" );
3 Note: The Color cast above is required since a hashtable holds objects of any type

in Table To:


© Northeast Parallel Architectures Center, Syracuse University, npac@npac.syr.edu

If you have any comments about this server, send e-mail to webmaster@npac.syr.edu.

Page produced by wwwfoil on Sat Nov 28 1998