import java.*: Interfaces and Inner Classes
By Chuck Allison, January 01, 2000
A Java interface is a weak substitute for multiple inheritance in C++, but it still manages to do a lot of what needs doing.
January 2000/import java.*/Figure 5
class StackTest2
{
public static void main(String[] args)
{
DynamicStack s = new DynamicStack();
doTest(s);
}
public static void doTest(DynamicStack s)
{
// No exceptions to check here:
System.out.println("Initial size = " + s.size());
s.push("one");
s.push(new Integer(2));
s.push(new Float(3.0));
s.push("one too many");
try
{
System.out.println("Top: " + s.top());
System.out.println("Popping...");
while (s.size() > 0)
System.out.println(s.pop());
}
catch(StackException x)
{
throw new InternalError(x.toString());
}
}
}
/* Output:
Initial size = 0
Top: one too many
Popping...
one too many
3.0
2
one
*/