Hello Ranchers,
I'm trying to structure the information from the OCP 8 Guide regarding Queue interface (Chapter 3).
As a programmer, I'm accustomed to divide between a FIFO-Queue and a Stack.
So if I would implement a Stack, I would offer operations like push, pop and top.
If I would implement a Queue, I would rather offer something like enqueue, dequeue and front.
The things, one learn in a university.
But
Java doesn't have this division anymore. The Stack implementation is outdated (as the book states). Java proposes a double-ended Queue implementations, that offer all possible methods for using it as a Stack and as a FIFO-Queue or even as a
two-in-one thing.
Now it's confusing.
If I understand correctly, it is more important to know the differences between the methods, returning a null or a false value and methods throwing an exception, than to know, which methods one would use on a FIFO-Queue and which methods on a Stack.
So the
question number one is...
Should I forget about a Stack and a FIFO-Queue and think about a general Queue, where I can put and get elements on/from the front and on/from the back? Or does the exam still have this division?
The
question number two is: the differences between LinkedList and ArrayDeque. The book says, ArrayDeque is more efficient implementation. Java API says also, the LinkedList allows null values, ArrayDeque - doesn't. Are this all differences one should know for the exam?
Thanks you.