MAPS

 

Some main methods for Maps are  .clear( ),  .containsKey(...),  .containsValue(...), 

.entrySet( ),  .get(...),  .isEmpty( ),  .entrySet(...),  .keySet( ),  .put(...), 

.putAll(...)  .remove(...),  .size( ),  and  .values( )

 

Both HashMap and TreeMap can use these methods.

 

 

Maps in general

 

■ Maps all employ key-value pairs of objects. Visualize them as two columns.

 

■ No duplicates of keys are allowed in Maps. 

 

■ Maps are not actually collections per se.  This is because they don't implement the Collection interface. However Maps are always associated with collections for discussion and usage.  Properties is not strictly a Map, either. That's because it preceeded Map and doesn't implement the Map interface.  However Properties is commonly associated with Maps because it's like a Map that only allows Strings.

 

  Everyday Maps are HashMap (for unordered keys) and TreeMap (which will automatically order your keys). 

 

  Printing a Map:  The default toString( ) method for Maps puts out the Map's contents like this:

 

key=value, key=value, key=value, key=value etc.