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:
- java.util.Stack is a class, not an interface (like Observable, bad choice)
- java.util.Properties extends java.util.Hashtable (rather than uses one)
- The java.util.Date class is a bit of a mess, and is not immutable!
- The java.util.Calendar class is a real mess
- No unsigned ‘byte’ type (this is a real pain and the source of many low-level bugs)
- java.sql.SQLException is a checked exception
- Arrays don’t use
Arrays.toString(array)as their defaulttoString()(how many SO questions has this caused?) Cloneableshouldn’t be a marker interface; it should have theclone()method andObject.clone()should not exist
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 likeboolean isIdentical(Object o), because you hardly ever need it! <should executecompareTo(Object o) < 0forComparableobjects (and similarly for>,<=,>=)