posted 20 years ago
Hi,
I may be wrong on this, but this is what I think:
IMHO, String.length() has to be a function and not a public final variable because String is implemented by java code itself. So, it doesn't know the length of the string until it creates it, and thus it can't provide it as a final variable. On the other hand, arrays for primitive types are implemented via an external platform-dependent dll, which returns the specified object. Thus, java code will know the length of an array when it gets it back from the dll, and thus can provide a public final property for the same.
P. S. Don't kill me if I'm wrong ;-)
_steve.