hierarchies
Hello.
I'm new to Java, OOP, and Internet forums. So much for introductions.
My question has to do with the various hierarchies that are mentioned in the docs. I have so far seen reference to the "class hierarchy", the "interface hierarchy", the "collection hierarchy", and the "package hierarchy".
How many of these hierarchies are there and are there any key relationships between them that one should know about?
Thank you.
> I posted my question over 12 hours ago and no one has
> responded.
It's weekend so it's a little slow.
Class and interface hierarchies are what you you build when you design your program making use of an important OO principle called inheritance. You use the extends keyword to do this.
In Java every class/interface must be in a package. A package is a library of classes/interfaces that are likely to be used together, and because of the package hierarchy, a way to resolve naming conflicts. (Two classes with the same name can coexist if they belong to different packages). You use the package and import keywords to handle packages.
The collections are dynamic data structures part of the standard Java library. Each class in the collections belong to both a class hierarchy and a package hierarchy. Associated with the collections are many interfaces but as far as I know there's no hierarchy defined among these interface.
> So, how many other hierarchies are there?
Three language level hierarchies: class, interface and package. (I'm sure I've missed one -:). The collections are an example of this. When it comes to the collections I'm sure you can think of other hierarchical organisations outside those supported by the Java language. So the number of possible hierarchies is only limited by your imagination really.
> I'm sure I've missed one -:).
You can make use of inner classes to express a hierarchical nested class structure. That's a fourth language level one.
And then you have the procedural aspects of Java with nested blocks of statements. That's a fifth.
So there are five in principle: class and interface extension, packages, and class and block nesting.