解釋一個Map.Entry

來源:互聯網
上載者:User

標籤:ext   equal   51cto   方法   對象   RoCE   bool   ide   除了   


public static interface Map.Entry<K,V>映射項(鍵-值對)。Map.entrySet 方法返回映射的 collection 視圖,其中的元素屬於此類。獲得映射項引用的唯一 方法是通過此 collection 視圖的迭代器來實現。這些 Map.Entry 對象僅 在迭代期間有效;更確切地講,如果在迭代器返回項之後修改了底層映射,則某些映射項的行為是不確定的,除了通過 setValue 在映射項上執行操作之外。

源碼
  /**     * Exported Entry for EntryIterator     */    static final class MapEntry<K,V> implements Map.Entry<K,V> {        final K key; // non-null        V val;       // non-null        final ConcurrentHashMap<K,V> map;        MapEntry(K key, V val, ConcurrentHashMap<K,V> map) {            this.key = key;            this.val = val;            this.map = map;        }        public K getKey()        { return key; }        public V getValue()      { return val; }        public int hashCode()    { return key.hashCode() ^ val.hashCode(); }        public String toString() { return key + "=" + val; }        public boolean equals(Object o) {            Object k, v; Map.Entry<?,?> e;            return ((o instanceof Map.Entry) &&                    (k = (e = (Map.Entry<?,?>)o).getKey()) != null &&                    (v = e.getValue()) != null &&                    (k == key || k.equals(key)) &&                    (v == val || v.equals(val)));        }
    /**     * @param args     * 解釋一個Map.Entry     */    public static void main(String[] args) {    }}//建立介面interface Inter {    //內部介面    interface Inter2 {        public void show();    }}//實現介面中的內部介面方法class Demo implements Inter.Inter2 {//重寫內部類介面方法    @Override    public void show() {    }

解釋一個Map.Entry

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.