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<>();

  


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM