Reputation: 23
I am trying to do this:
Queue<Integer> Q = new ArrayList<Integer>();
But My IDE gives me error.
Can any one please tell me, Why I can't create an object of ArrayList
in a class of queue?
Upvotes: 0
Views: 2665
Reputation: 101
Using of ArrayDeque instead of LinkedList makes it a little bit faster ...
Queue<Integer> q = new ArrayDeque<>();
Upvotes: 0
Reputation:
You can't do that because ArrayList
does not implement
Queue
. You could use a LinkedList
instead:
Queue<Integer> q = new LinkedList<>();
Upvotes: 4