Object-Oriented development method Overview [Java Study Notes 2]

Source: Internet
Author: User

1.5 Relationship between classes (-2) ]UML classifies the relationships between classes into the following five types of L associations: Class A and Class B instances have specific mappings. L dependency: services provided by Class A and Class B. L aggregation: Class A is the overall Class, Class B is the local class, and Class A objects are composed of Class B objects. L generalization: Class A inherits class BL implementation: Class A implements Class B interface 1.5.1 Association refers to the specific correspondence between classes, which is expressed by solid arrows in UML. There are three forms of association: 1. one-to-one association: 2. one-to-Multiple Association: 3. many-to-many Association: The Association can also be divided into one-way Association and two-way Association 1.5.2 dependency refers to the call relationship between classes, which is expressed by the arrow with a dotted line in UML. If Class A is an attribute or method of Class B, or Class A is responsible for instantiating Class B, Class A can be said to depend on Class B. 1.5.3 aggregation refers to the relationship between the whole and the part, which is expressed by a diamond arrow with solid lines in UML. Clustering can be divided into two types: 1. the clustered subsystem is allowed to be disassembled and replaced, which is a common clustering relationship. 2. The clustered sub-system cannot be disassembled or replaced. This clustering relationship is a strong clustering relationship or a composition relationship. (Expressed by solid diamond arrows with solid wires in UML) 1.5.4 generalization refers to the inheritance relationship between classes and is represented by a triangular arrow with solid wires in UML. 1.5.5 implementation refers to the relationship between classes and interfaces. It is represented by a triangular arrow with dotted lines in UML. 1.5.6 differentiate dependency, association, and aggregation. 1. dependency characteristics: For two relatively independent systems, when a system is responsible for constructing instances of another system or relying on services of another system, the two systems mainly reflect dependency. 2. Features of the association relationship: When an instance of a system has a fixed ing relationship with a specific instance of another system, the two systems are associated. 3. clustering relationship characteristics: When system A is added to system B and becomes an integral part of system B, system B and system A are clustered. Java applications fully access 2.1java source file 2.1.1 source file structure l zero or one package declaration statement l zero or multiple package import statements l zero or multiple classes declare l zero or multiple interfaces declaring a source file can only have one class or interface that is public, the source file name is the same as the public class or interface name. 2.12 package declaration statement must be in the first line of the Java source file. (Ignore comment lines) and only one package declaration statement can be found. The role of the package: classes with the same name can be distinguished, access permission control can be implemented, and various classes in Java applications can be divided and organized. For example, if a class accesses a class from another package, this class must be introduced through the Import Statement. The package introduction statement does not mean that the Java Virtual Machine will load the class and initialize the class. Note: 1. if a class references the Same Name class from two different packages at the same time, the program must distinguish the two classes by the full Class Name of the class. despite the symbol ". "represents the hierarchy of vehicles between packages, but each package is independent. The top-level package does not contain classes in the sub-package. 3. The order of package and import statements is fixed. 2.1.4 method declaration each method in Java belongs to a specific class, and the method declaration must be included in the class declaration. Return Statement: ends execution of this method and returns data to the caller of this method. 2.1.5 Declaration of the main () method of the program's entry method the declaration of the main () method must simultaneously sign the following four conditions: 1. access restriction: public2. static method: static3. Parameter Restriction: Main (string [] ARGs) 4. return type: void is of the final type by default due to static modification, It cannot be overwritten by the quilt class, but it can be hidden by the quilt class.! Therefore, you can add final before the main () method. 2.1.7 comments three forms of comments: 1. // All characters in text from "//" to the end of the line are ignored by the compiler as comments. /* All characters from/* to */are ignored by the compiler */3. all characters in/** text */from/** to */are ignored by the compiler. Such annotations are used as the content of the javadoc document. References Java Object-Oriented Programming sun weiqin Electronics Industry Press
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.