The concept of stack is not unique in java. It applies not only in the programming world but everywhere, so I will explain the basic concept.
When you put items in a stack you place each one of them after the other. But when you try to take these items from the stack you can only take the last one you entered not the first. If you have a stack of plates you put one on top of the other, but you cannot take the one at the bottom (the one you put first), you must take the one at the top, which was the one you placed last.
In java, you can store objects in a stack the same way. Assume you call push several times:
when you call the pop command you will get the value: "CCC". If you call pop again you will get the "BBB". You will be getting the items in the opposite order you put them
Now if you use an ArrayList and do this:
And then try to get the values with method get(int i) , you will have the values in the order placed in them:
I am working creating a fully encapsulated, homogeneous singly linked data structure. The Listing class and SinglyLinkedList class that are part of the whole application compile fine, but the problem ...