wildcard.java

来自「Java面向对象编程(随书配套源代码) 阐述了面向对象编程的思想」· Java 代码 · 共 38 行

JAVA
38
字号
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 + =
减小字号Ctrl + -
显示快捷键?