public class HashMapII
extends java.lang.Object
| Constructor and Description |
|---|
HashMapII()
Creates a new HashMap for integer keys and values.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
containsKey(int key)
Returns true if this map contains a mapping for the specified key.
|
int |
get(int key)
Returns the value to which the specified key is mapped, or null if this
map contains no mapping for the key.
|
int |
get(int key,
int def)
Returns the value to which the specified key is mapped, or null if this
map contains no mapping for the key.
|
IteratorI |
keys()
Returns an iterator over the keys in this HashMap.
|
int[] |
keysArray()
Returns an array with all keys in this HashMap.
|
void |
put(int key,
int value)
Associates the specified value with the specified key in this map.
|
int |
size()
Returns the number of key/value pairs in the hashmap.
|
public int size()
public void put(int key,
int value)
key - key with which the specified value is to be associatedvalue - value to be associated with the specified keypublic int get(int key)
key - the key whose associated value is to be returnedpublic int get(int key,
int def)
key - the key whose associated value is to be returneddef - the default key valuepublic boolean containsKey(int key)
key - The key whose presence in this map is to be testedpublic IteratorI keys()
public int[] keysArray()