문제

what is the meaning of the following sequence diagram and exactly the constructor(that is represented as a create object)?

enter image description here

도움이 되었습니까?

해결책 2

It means that ClassA instantiates ClassB. The arrow represents that the constructor of ClassB is called by ClassA

다른 팁

The message's name "Class B()" is wrong : it should be "create".
Is that what confusing you ?

Chriss, hopefully you've figured it out by now. Please accept Cratylus's answer as it is correct.

Here is an example in Java:

Main.java

package com.example.umlquestion;

// (e.g. your application that makes and uses an instance of ClassA)
public class Main {
    public Main() {
        // this calls ClassA's constructor, which will then call ClassB's constructor
        private ClassA instanceA = new ClassA(); 
        // ...
    }
}

ClassA.java

package com.example.umlquestion;

public class ClassA  {
    private ClassB instanceB;
    public ClassA() {
        instanceB = new ClassB();
        // ...
    }
    // ...
}

ClassB.java

package com.example.umlquestion;

public class ClassB  {
    public ClassB() {
        // ...
    }
    // ...
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top