the
same
method name with identical arguments and return type, well, it just *had* to
be overriding, right? Well, sure shows me!
No, you are applying the statement too broadly. You seem to have not
grasped the fact that for all intents and purposes, an inner class is a
*seperate* class from its containing class[es]. It has special access
to its containing class[es], true, but that's irrelevant. When you add
a method to an inner class you are not adding it to any containing
class, so you H&R's statement does not apply.
Mr. Bollinger: I appreciate that this may be the way Java works, but I fear
we must be interpreting the English language differently. If the main
property of an inner class is that it cannot exist without an enclosing
instance, then semantically yes I cannot grasp how anybody can claim that an
inner class can be considered "separate" from its containing class. If you
separate it from its containing class it ceases to exist and turns into a
top-level class. This "un-separateness" is a defining characteristic of what
an inner class is - it cannot exist independently and therefore is not
separate.
Before Java had inner classes, the relationship between two classes
prescribed the way method names could be reused and words like "separate"
and "unrelated" may have had a clear and distinct meaning. With the
introduction of inner classes to Java, I believe the words "separate" and
"unrelated" became obsolete. For someone (such as myself) who didn't grow up
with the jargon, (ie follow Java since 1995) the statements "an inner class
is separate from its containing class" or "an inner class is unrelated to
its containing class" simply must be refused as false. If it's acceptible to
say this in Java, fine, but it's no longer English we're speaking here.
There *must* be better terms than "related" or "not separate" to describe
the relationship between a child and a parent that makes it distinct from
the relationship between an outer and inner class. Anybody any ideas?
Would you disagree with me that the reuse of method names involves three and
not two cases, and that hiding is an alternative to overriding and
overloading?
No. Perhaps we're having another terminology problem, but the word
"extend" has specific meaning in the context of Java: the relationships
between a class and each of its superclasses. As we've been discussing,
a class can override methods inherited from any class it extends, and it
can offer overloaded versions of those methods.
I accept this. Following this line of thought would you say the reuse of
method names in a static context in two classes that share a parent/child
relationship are participating in "hiding"? Is this behaviour the same as
for the reuse of method names in two classes that share an inner/outer
relationship? (if you forget for a second that the way the hiding method
would reference the method it's hidden?)
Thanks,
Ben.