admin wrote:I am not sure I understand your question correctly. Could you please be a little more clear so that I can help?
thank you,
Paul.
Code: Select all
Class A
{
String name ="";
List<B> list =new ArrayList<>();
}
Class B
{
}
2 points quite straight forward considering the above code:
1) A has a
B because it's going to be a list of B, therefore the relation
has-a. Instead you say that A has-a list.. which would not be compliant with an Object Oriented Design way to see these relationship.
2) Class A
has-a String does not make sense to me. If the scope of the relationship is creating a Object Oriented Design relation has-a. The fact that a class has-a String is certainly true but not critical in terms of coupling.
Furthermore in this
http://www.coderanch.com/t/616942/java- ... ation/OCJP link I got confirmed by another user that there is a has-a relationship between the List generic element and the class containing it.
Basically I would like to know why List<B> list = new ArrayList<>(): would not create a has-a relationship A has a B.
Thanks in advance.
Always available for further clarification about the question.
The_Nick.