From charlesreid1

(Created page with "<pre> public interface Stack<E> { int size(); boolean isEmpty(); void push(E e); E pop(); E peek(); } </pre> =Flags= {{DataStructuresFlag}} Category...")
 
No edit summary
 
(One intermediate revision by the same user not shown)
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. This is much simpler than the Stack interface in the Java API.
<pre>
<pre>
public interface Stack<E> {  
public interface Stack<E> {  

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