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

在这里插入图片描述
在这里插入图片描述


本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!

相关文章

立即
投稿

微信公众账号

微信扫一扫加关注

返回
顶部