Package collections
Class MapExample
- java.lang.Object
-
- collections.MapExample
-
public class MapExample extends java.lang.Object
Example forMap
interface.Wraps a
Map
instance 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>
map
Wrapped 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 void
dump()
Dumps map to the console.java.util.Map
getMap()
Returns wrapped map.void
read(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.IOException
Count 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.
-
-