Representing Relationships
UML and Java may be languages for software development, but they exist in different planes of reality. UML occupies the visual world, whereas Java is textual in nature.
UML is also richer than Java in the sense that it offers more abstract and powerful ways of expressing a particular concept or relationship. However, there is generally only one way to represent that concept or relationship in the Java language.
1. Inheritance
The UML concept of generalization is analogous to inheritance in Java. Generalization maps directly to the extends keyword and is shown visually via a line with a triangle at the end nearest the super class.
2. Realization
In Java, a class may implement one or more interfaces. The Java keyword implements maps to the concept of realization in UML.
3. Dependency
Anytime a class uses another class in some fashion, a dependency exists between the two (classes---add by Fitzwilliam,也就是说,dependency是类之间的关系).
In the UML, a dependency is shown via a dotted line with an arrow touching the class that is causing the dependency.
A dependency exists if a class:
l Has a local variable based on another class