Home  >  Q&A  >  body text

What is the general relationship between Java classes? (non-aggregated combination)

After understanding the relationship between java classes, we have basically understood the aggregation and combination relationships, but association relationships In addition to aggregation and combination general association relationships are What kind of thing?

Since the association relationship is an ownership relationship, in addition to the combination relationship and aggregation relationship, what are the remaining general association relationships like. . . (Best code, please)

My Baidu explains combination and aggregation. Are there only combination and aggregation in related relationships?
It is said on the Internet that combination and aggregation are special relationships, but it is not said that relationships are divided into these two types. I can't think of other relationships besides these two.

巴扎黑巴扎黑2713 days ago973

reply all(1)I'll reply

  • 世界只因有你

    世界只因有你2017-05-17 10:02:56

    • Inheritance relationship (subclass inherits the functions of parent class and parent interface) is clearly identified with extends

    class SuperClass{//这是父类}
    // 使用extends 继承父类的功能
    class SubClass extends SuperClass{//这是之类}
    1. To implement the relationship and implement the interface excuse, use the implement identifier

    interface Classb{//这是接口,用interface申明}
    class Classc implement Classb{// 用implement 来实现接口内的功能能}
    1. Dependency For example: Class b needs to be used as a parameter in class a

    public class Classb{}
    class Classc
    {
        public static void method(Classb a)
        // 在这里使用了Classb的对象作为了参数
         {
         System.out.println(a);
         }
    }
    1. Association Relationship: Association reflects a strong dependency relationship at the semantic level between two classes, such as me and my friend. This relationship is stronger than dependence. There is no contingency of dependence, and the relationship is not temporary. It is generally long-term, and the relationship between both parties is generally equal.

    The rest is what you call the relationship between combination and aggregation

    reply
    0
  • Cancelreply