Problem

Using the class java.util.Stack, define a class OurStack that implements the interface Sta...

Using the class java.util.Stack, define a class OurStack that implements the interface StackInterface, as given in Listing.

LISTING 1 An interface for the ADT stack

public interface StackInterface{  /** Adds a new entry to the top of this stack.  @param newEntry an object to be added to the stack */  public void push(T newEntry);  /** Removes and returns this stack’s top entry.  @return either the object at the top of the stack or, if the  stack is empty before the operation, null */  public T pop();  /** Retrieves this stack’s top entry.  @return either the object at the top of the stack or null if  the stack is empty */  public T peek();  /** Detects whether this stack is empty.  @return true if the stack is empty */  public boolean isEmpty();  /** Removes all entries from this stack */  public void clear();} // end StackInterface

Step-by-Step Solution

Request Professional Solution

Request Solution!

We need at least 10 more requests to produce the solution.

0 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the solution will be notified once they are available.
Add your Solution
Textbook Solutions and Answers Search
Solutions For Problems in Chapter 5
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT