Why is java.util.Observable not an abstract class?

Quite simply it’s a mistake that Observable is a class at all, abstract or otherwise.

Observable should have been an interface and the JDK should have provided a convenient implementation (much like List is an interface and ArrayList is an implementation)

There are quite a few “mistakes” in java, including:

While on the soapbox, in terms of the language itself, IMHO:

  • == should execute the .equals() method (this causes loads of headaches)
  • identity comparison == should either be === like javascript or a dedicated method like boolean isIdentical(Object o), because you hardly ever need it!
  • < should execute compareTo(Object o) < 0 for Comparable objects (and similarly for >, <=, >=)

Leave a Comment