2005-06-15

We spell it s-u-b-t-y-p-e around here

Tim Bray wonders why generic declarations extend rather than implement interfaces in Java 5.0.

The answer is simple: extends is how you spell "is a subtype of" in Java. The declarative semantics of implements is likewise "is a subtype of", but operationally it further means "provides an implementation for", and is a relationship specifically between a class and an interface. Types as such don't implement other types.

By the same token, interfaces extend their superinterfaces and always have. They also extend Object, which is a class.

No comments: