Chapter 21: Data Structures and java.util

Page 505: Program 21.1 doesn't work because Java doesn't allow subclasses to restrict return types. However, you can still limit a stack to jsut strings like this:

public class StringStack extends java.util.Stack {

  public Object push(Object item)
    super.push((String) item);
  }

}
Page 510: the first code fragment on the page should read


for (Enumeration e = ht.elements(); e.hasMoreElements(); ) {
  System.out.println(e.nextElement());
}

Corrections to Other Chapters
[ Cafe Au Lait | Books | Trade Shows | Links | FAQ | Tutorial | User Groups ]
Copyright 1996-9, 2003 Elliotte Rusty Harold
elharo@metalab.unc.edu
Last Modified January 2, 2003