push method
Implementation
void push(int pageIndex) {
// Check if the last index is pushed again
if (pageIndex == last)
throw Exception("pageIndex pushed cannot be the same as the last index.");
// If the pushed item exist on the stack, remove it
remove(pageIndex);
// Add index
addLast(pageIndex);
}