CSC300: ADTs in Java [3/9] |
In Java we write this as follows (using Strings instead of plates):
01 |
package algs13; public class StackOfStrings { public StackOfStrings { /* ... */ } public boolean isEmpty () { /* ... */ } public void push (String item) { /* ... */ } public String pop () { /* ... */ } } |
We use the ADT as follows:
08 |
StackOfStrings stack = new StackOfStrings(); stack.push("a"); if (! stack.isEmpty()) { String item = stack.pop(); } |