up previous next contents
Next: Abstract Classes and methods Up: Extending Classes Previous: The object class   Contents

Anonymous classes

  • Use these when the weight of a full class seems too much for your needs.
  • Extend a class or implement an interface.
  • Defined at the same time they are created with new.
  • Defined in the new expression.
  • Cannot have their own constructors.
  • Can easily become hard to read.
  • Avoid anonymous classes longer than six lines.
  • Use them only in the simplest of expressions.


up previous next contents
Next: Abstract Classes and methods Up: Extending Classes Previous: The object class   Contents