class:java.util.AbstractMap
line:381
public abstract class AbstractMap<K,V> implements Map<K,V> {
* Sole constructor. (For invocation by subclass constructors, typically
protected AbstractMap() {
...
* {@inheritDoc}
public Collection<V> values() {
if (values == null) {
values = new AbstractCollection<V>() {
public Iterator<V> iterator() {
return new Iterator<V>() {
private Iterator<Entry<K,V>> i = entrySet().iterator();
public boolean hasNext() {
return i.hasNext();
}
public V next() {
return i.next().getValue();
}
public void remove() {
i.remove();
}
};
}
public int size() {
return AbstractMap.this.size();
}
public boolean contains(Object v) {
return AbstractMap.this.containsValue(v);
}
};
}
return values;
}
public abstract Set<Entry<K,V>> entrySet();
}
抽象类中的抽象方法,可以在本抽象类中使用,但其实现由继承该抽象类的子类实现。