public static class AbstractMap.SimpleEntry<K,V> extends Object implements Map.Entry<K,V>, Serializable
Constructor and Description |
---|
SimpleEntry(K key, V value)
从表示指定键的指定键的映射创建一个表示指定值的映射项。
|
SimpleEntry(Map.Entry<? extends K,? extends V> entry)
创建一个表示指定项的相同映射的条目。
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object o)
将指定的对象与此项的相等性进行比较。
|
K |
getKey()
返回对应于此项的键。
|
V |
getValue()
返回对应于此项的值。
|
int |
hashCode()
返回此Map项的哈希代码值。
|
V |
setValue(V value)
用指定的值替换对应于此项的值。
|
String |
toString()
返回此Map项的字符串表示形式。
|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
comparingByKey, comparingByKey, comparingByValue, comparingByValue
public SimpleEntry(K key, V value)
key
为代表的关键
value
-价值为代表的这项
public boolean equals(Object o)
true
如果给定的对象也是一个映射项和两项表示相同的映射。更正式地说,两项
e1
和
e2
表示相同的映射,如果
(E1。getkey() = =零?E2。getkey() = = null:E1。getkey()。等于(E2。getkey()))&(E1。getvalue() = =零?E2。getvalue() = = null:E1。getvalue()。等于(E2。getvalue()))这保证了
equals
方法正常工作在
Map.Entry
接口的不同实现。
public int hashCode()
e
哈希码被定义为:
(E getkey() = =零?0:大肠getkey() ^ hashcode())。(E getvalue() = =零?0:大肠getvalue() hashcode())。这确保
e1.equals(e2)
意味着
e1.hashCode()==e2.hashCode()
任何两项
e1
和
e2
,由
Object.hashCode()
一般合同要求。
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2014, Oracle and/or its affiliates. All rights reserved.