日期:2014-05-20 浏览次数:20676 次
public Set<K> keySet() { Set<K> ks = keySet; [color=#0000FF]//这个keySet是什么? 没有定义啊?[/color] return (ks != null ? ks : (keySet = new KeySet())); }
public Set<K> keySet() { if (keySet == null) { keySet = new AbstractSet<K>() { public Iterator<K> iterator() { return new Iterator<K>() { private Iterator<Entry<K,V>> i = entrySet().iterator(); public boolean hasNext() { return i.hasNext(); } public K next() { return i.next().getKey(); } public void remove() { i.remove(); } }; } public int size() { return AbstractMap.this.size(); } public boolean contains(Object k) { return AbstractMap.this.containsKey(k); } }; } return keySet; }
------解决方案--------------------
一定是存在的变量了啦,好好找找。