I have seen 2 valid declarations of the LinkedList class in Collections Framework in Java.
What exactly is the difference between these 2 implementations?
Queue is an interface which LinkedList class implements.
In Your first case you a is a LinkedList reference to a LinkedList object. In the latter, a is a Queue interface reference pointing to a LinkedList object so, in this last case you will be only able to execute those service of LinkedList which are included in Queue interface.
There is just one implementation in your code: LinkedList.
Queue is one of the multiple interfaces implemented by LinkedList class.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With