Java之多继承

Java多继承

关于Java多继承,众所周知是不支持多继承,但这个一般指Java类不支持多继承,主要是由于避免子类被引用时候统同一方法无法判断应该使用哪个父类的方法;
有种特殊情况下,Java是支持多继承的,那就是接口(接口中的方法都是申明,没有具体实现):
如下所示:

public interface BlockingDeque<E> extends BlockingQueue<E>, Deque<E> {
  /*
     * We have "diamond" multiple interface inheritance here, and that
     * introduces ambiguities.  Methods might end up with different
     * specs depending on the branch chosen by javadoc.  Thus a lot of
     * methods specs here are copied from superinterfaces.
     */

    /**
     * Inserts the specified element at the front of this deque if it is
     * possible to do so immediately without violating capacity restrictions,
     * throwing an IllegalStateException if no space is currently
     * available.  When using a capacity-restricted deque, it is generally
     * preferable to use {@link #offerFirst offerFirst}.
     *
     * @param e the element to add
     * @throws IllegalStateException    {@inheritDoc}
     * @throws ClassCastException       {@inheritDoc}
     * @throws NullPointerException     if the specified element is null
     * @throws IllegalArgumentException {@inheritDoc}
     */
    void addFirst(E e);
    .....

}

Java之多继承_第1张图片
Java之多继承_第2张图片

你可能感兴趣的:(Java)