Question
Can someone help me get a better understanding of StackInterface in java? I also am having trouble with some of these methods i need to
Can someone help me get a better understanding of StackInterface in java?
I also am having trouble with some of these methods i need to write.
public interface StackInterface
/**
* Add element to top of stack.
* @param newEntry item to add to stack.
*/
public void push(T newEntry);
/**
* Remove and return top element from stack.
* @return top element.
* @throws EmptyStackException if the stack is empty
*/
public T pop();
/**
* Return top element from stack without modifying stack.
* @return Element on top of stack.
* @throws EmptyStackException if the stack is empty
*/
public T peek();
/**
* Whether stack is empty.
* @return True if stack is empty, false otherwise.
*/
public boolean isEmpty();
/**
* Remove all elements from stack.
*/
public void clear();
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started