Next:
pop() Method
Up:
Java Stacks
Previous:
Stack Methods
Contents
push()
Method
To add an element to the top of the stack, we use the
push()
method. For example,
Output