-1
I’m a beginner in programming and I was studying some data structures in the Java language. When I started studying about the "stack" structure, I had the following question: Let’s say I have a vector with five spaces (indexes ranging from 0-4), but only four spaces (indexes ranging from 0-3) are filled, so the "top of the stack" is the value "null"which is in the index "4" (which is empty), or is the value "3", which is not the last index of the stack that makes up this vector, but is the last space of the vector that has a value other than null?
Illustrating: vector 1 = [1, 2, 3, 4, null] - The top of the stack is either Indice "3" or index "4"?
Java offers the class Stack extending the Vector class by adding stack handling operations. There is also the Vector class Linkedlist representing a doubly chained list that offers editing methods at both ends of the list.
– Augusto Vasques