Hi there, I have some questions regarding declarations and instantiations. If you can answer any of these, please help.
Sometimes I see queue, deque, LinkedList being used.
For instance, sometimes I see this written:
Queue<TreeNode> queue = new LinkedList<>();or
Deque<TreeNode> dq = new ArrayDeque<>();2) Why would I use a Queue vs a Deque?
Also, for the first line, can I instead say
Queue queue = new Queue<>();
Finally, what are the rules for declaration vs instantiation? For example, if I declare as a Deque on the left side, what type can I instantiate it as on the right side?
Also why am I allowed to say Queue queue = new LinkedList<>() when they are not the same type?