📄 wildcard.java
字号:
package chapter11;
import chapter7.*;
public class Wildcard
{
public static boolean isEmpty( Stack<?> s)
{
return s.isEmpty();
}
public static boolean isEmpty2(Stack2<?> s)
{
return s.isEmpty();
}
public static void main(String args[])
{
Stack<String> strStack = new Stack<String> (10);
Stack<Integer> iStack = new Stack<Integer> (10);
Stack<Double> dStack = new Stack<Double> (10);
strStack.push("String");
if(!Wildcard.isEmpty(strStack))
{
System.out.println(strStack.pop());
}
if(!Wildcard.isEmpty(iStack) && !Wildcard.isEmpty(dStack) )
{
System.out.println("iStack和dStack 都是空栈");
}
Stack2<Duck> duckStack = new Stack2<Duck> (10);
Stack2<Sheep> sheepStack = new Stack2<Sheep> (10);
if(!Wildcard.isEmpty2(duckStack) && !Wildcard.isEmpty2(sheepStack) )
{
System.out.println("duck和sheepStack 都是空栈");
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -