Mike Schilling wrote:
> Not very good OO programmers, are they? Every array class has the
> same "length" field, so it should be moved up into an abstract
> superclass.
Actually, it's each array /instance/ that has a 'length'. Such a field is an
instance member, not a class member.
Furthermore, it isn't actually a field. Even were 'length' actually a field,
and there were an actual superclass that defined it, its behavior would be the
same, from the Java language perspective, as observed today.
The implementation of 'length' does provide that abstractness, in that the
implementation is not specific to each array, but general for all arrays.
Conceptually, it's just precisely exactly quite as if indeed there were an
abstract array superclass that defines 'length'. The definition of 'length'
lives in the (imaginary) abstract superclass of array, the instance and
initialization of a 'length' live in each array instance.
So I have to disagree, 'they" are pretty good OO programmers.
--
Lew