From charlesreid1

No edit summary
No edit summary
 
Line 1: Line 1:
When implementing a Stack class, according to the [[Abstract Data Types]] page, you'll want to use an interface in Java. Here's an example Stack interface to enforce a set of uniform methods:
When implementing a Stack class, according to the [[Abstract Data Types]] page, you'll want to use an interface in Java.  
 
Here's an example Stack interface to enforce a set of uniform methods. This is much simpler than the Stack interface in the Java API.


<pre>
<pre>

Latest revision as of 05:43, 4 June 2017

When implementing a Stack class, according to the Abstract Data Types page, you'll want to use an interface in Java.

Here's an example Stack interface to enforce a set of uniform methods. This is much simpler than the Stack interface in the Java API.

public interface Stack<E> { 
    int size();
    boolean isEmpty();
    void push(E e);
    E pop();
    E peek();
}


Flags