比如我有 class A,class B extends A;class template<A>,class template<B>。
要在 template<B> 里存一个名叫 template_parent 的实例变量指向一个 template<A>,而 template<A> 的 template_parent 为 null。定义 template_parent 时想写 template<? is extended by B> 但是不让写。为什么 Java 不让这么写?我该怎么可以绕开这个限制来表达相同的意思?
Update: 好吧我欢乐多~~ <? is extended by B> 和 <B> 是一样的。。。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
不是一样的哦。如果你想指定B的parent,或者B的parent的parent……可以用
<? super B>。<? is extended by V>可以用<? super V>来表示。