public class HashMap extends Object implements Map, Serializable
HashMap
,
Serialized FormModifier and Type | Field and Description |
---|---|
private Hashtable |
hiddenMap |
private Set |
keySet
Proxy to the realHiddenMap keys Set
|
private static Long |
nullValue |
private Map |
realHiddenMap |
private static long |
serialVersionUID
The following elements are required to ensure compatibility with
the J2ME version of this class in serialization/deserialization
operations.
|
private Collection |
values
Proxy to the realHiddenMap values Collection
|
Constructor and Description |
---|
HashMap()
Default constructor, creates a new empty Map
|
HashMap(int s)
Constructor, creates a new Map with initial size
|
HashMap(int s,
float lf)
Constructor, creates a new Map with initial size and load factor
|
Modifier and Type | Method and Description |
---|---|
void |
clear()
Remove all mappings from this map.
|
boolean |
containsKey(Object key)
Returns true if this map contains a mapping for the specified
key.
|
Object |
get(Object key)
Returns the value to which this map maps the specified
key.
|
private Map |
getData() |
boolean |
isEmpty()
Returns true if this map contains no key-value mappings.
|
Set |
keySet()
Returns a set view of the keys contained in this map.
|
Object |
put(Object key,
Object value)
Associates the specified value with the specified key in this map
(optional operation).
|
private void |
readObject(ObjectInputStream in)
A customized readObject() method is needed to ensure compatibility with
the J2ME version of this class in serialization/deserialization
operations
|
Object |
remove(Object o)
Removes the mapping for this key from this map if present (optional
operation).
|
private void |
setData(Map data) |
int |
size()
Returns the number of mappings in this map.
|
String |
toString() |
Collection |
values()
Returns a Collection view of the values contained in this map.
|
private void |
writeObject(ObjectOutputStream out)
A customized writeObject() method is needed to ensure compatibility with
the J2ME version of this class in serialization/deserialization
operations
|
private transient Map realHiddenMap
private transient Set keySet
private transient Collection values
private static final long serialVersionUID
private static final Long nullValue
private Hashtable hiddenMap
public HashMap()
public HashMap(int s)
public HashMap(int s, float lf)
public boolean isEmpty()
Map
public Object remove(Object o)
Map
public Object put(Object key, Object value)
Map
public Object get(Object key)
Map
public int size()
Map
public boolean containsKey(Object key)
Map
containsKey
in interface Map
key
- key whose presence in this map is to be tested.interface
public void clear()
Map
public Set keySet()
Map
public Collection values()
Map
private void writeObject(ObjectOutputStream out) throws IOException
IOException
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException
IOException
ClassNotFoundException
private void setData(Map data)
private Map getData()