Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

Class relationship

Shulou Source: shulou.com Published: 2022-06-03 07:41:31 11月06日 Update

Association:

There are two-way and one-way.

The two-way association between class An and class B can be an attribute of each other.

One-way means that one of the classes acts as an attribute in the other class

For example:

Public class Person {

Hourse head=new Hourse ()

}

Dependence:

Dependency is only one-way, and there is no attribute problem. For example, class A depends on class B, which indicates that there are three types of B in class A:

First, class B is global.

Second, class B is instantiated in class A.

Third, class B is passed as a parameter.

Public class Person {

Public void buy (Hourse hs) {

}

}

Tags: One-way two-way association usage global parameter only instance other party method category problem Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Tech Info NVidia OPPO Reno Microsoft Redmi