cannot instantiate the type

cannot instantiate the type

 

instantiate ---instant--instance实例---instant立刻的迫切的-----instantiate实例化

无法实例化这个类

 

我的error:cannot instantiate the type Queue

Queue<Integer>[] queues=new Queue[radix];
		for(int i=0;i<radix;i++)
			queues[i]=new Queue<Integer>();

 

通过stackflow:java.util.Queue是个接口,当然不能实例化了****因为之前常用stack,所以以为queue也是类,没想到就栽了

【P.S.想起来之前二叉树广度优先遍历了,也是用的queue,查看了一下,果然是Queue<BinTreeNode> queue=new LinkedList<BinTreeNode>();

 

java.util.Queue is an interface so you cannot instantiate it directly. You can instantiate a concrete subclass, such as LinkedList:

Queue<T> q = new LinkedList<T>

这样才对嘛

		Queue<Integer>[] queues=new LinkedList[10];
		for(int i=0;i<10;i++)
			queues[i]=new LinkedList<>();

  

posted @ 2017-03-17 10:04  Nicolellu  阅读(7113)  评论(0编辑  收藏  举报