Answer the question
In order to leave comments, you need to log in
What is stored in the field?
There is a class "A", which in its method passes itself to the constructor of another class "B". Class "B" has a field for class "A". Class "B" in its method passes a field with class "A" to the constructor of class "C", class "C" also has a field for class "A". Class "C" further passes the field with the class "A" to the class "D", etc. What is stored in the fields "a", the same one object? Or are copies made? And is it correct to pass so far through all classes?
public class classA {
classB b;
publc void init(){
b = new classB(this);
}
}
public class classB {
classA a;
classC c;
publc classB (classA a){
this.a = a;
}
publc void init(){
c = new classC(a);
}
}
public class classC {
classA a;
classD d;
publc classC (classA a){
this.a = a;
}
publc void init(){
d = new classD(a);
}
}
Answer the question
In order to leave comments, you need to log in
What is stored in the "a" fields, the same one object?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question