zoukankan      html  css  js  c++  java
  • 抽象类的抽象方法及使用

    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();
    }


    抽象类中的抽象方法,可以在本抽象类中使用,但其实现由继承该抽象类的子类实现。

  • 相关阅读:
    字符串匹配之BF算法
    python里的反射(自学习)
    python的super()以及父类继承
    @staticmethod
    @classmethod
    scrapy
    mongodb
    js注入提取伪元素选择器
    execjs
    base64解密
  • 原文地址:https://www.cnblogs.com/tao_/p/2220537.html
Copyright © 2011-2022 走看看