| Introduction to OOP | Chapter 10: Subclasses and Subtypes: | next | previous | audio | real | text |
interface Stack {
public void push (Object value);
public Object top ();
public void pop ();
}
Notice how the interface itself says nothing about the LIFO property,
which is the key defining feature of a stack. Is the following a stack?
class NonStack implements Stack {
public void push (Object value) { v = value; }
public Object top () { return v; }
public void pop () { v = null; }
private Object v = null;
}