Package collections
Class MapExample
- java.lang.Object
-
- collections.MapExample
-
public class MapExample extends java.lang.ObjectExample forMapinterface.Wraps a
Mapinstance and performs basic I/O.- See Also:
HashMapExample,LinkedHashMapExample
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.Map<java.lang.String,java.lang.Integer>mapWrapped map.
-
Constructor Summary
Constructors Constructor Description MapExample(java.util.Map<java.lang.String,java.lang.Integer> map)Creates a new map wrapper.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddump()Dumps map to the console.java.util.MapgetMap()Returns wrapped map.voidread(java.lang.String file)Count number of words in the specified file.
-
-
-
Method Detail
-
read
public void read(java.lang.String file) throws java.io.IOExceptionCount number of words in the specified file.- Parameters:
file- file to read.- Throws:
java.io.IOException- if an I/O error occurred.
-
dump
public void dump()
Dumps map to the console.
-
getMap
public java.util.Map getMap()
Returns wrapped map.- Returns:
- wrapped map.
-
-