📄 wildcardbound.java
字号:
package chapter11;
import java.util.*;
import chapter7.*;
public class WildcardBound
{
public static boolean isEmpty( Stack<? extends List> s )
{
return s.isEmpty();
}
public static boolean isEmpty2(Stack2<? super Duck> s)
{
return s.isEmpty();
}
public static void main(String args[])
{
Stack<List> lsStack = new Stack<List>(10);
Stack<String> strStack = new Stack<String>(10);
Stack2<Animal> animalStack = new Stack2<Animal>(10);
Stack2<Duck> duckStack = new Stack2<Duck>(10);
Stack2<Wolf> wolfStack = new Stack2<Wolf>(10);
//WildcardBound.isEmpty(strStack); //WildcardBound类型中的方法isEmpty( Stack<? extends List> s )对于参数Stack<String>不适用
WildcardBound.isEmpty(lsStack);
WildcardBound.isEmpty2(animalStack);
WildcardBound.isEmpty2(duckStack);
//WildcardBound.isEmpty2(wolfStack);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -