Save
Java part 2
Stacks
Save
Share
Learn
Content
Leaderboard
Learn
Created by
Ruby
Visit profile
Cards (5)
Stacks
LIFO: last in, first out data structure
creating a stack
import java.util.Stack;
Stack<String>callStack=newStack<String>();
Stack .push() method
add an element to the top of the stack
callStack.push("main");
stack
.pop()
method
remove an element from the top
of the stack and
returns that element
stack
.peek()
method

return the element at the top of the stack