5
If I create for example two classes and place the class Funcionario with a variable Empregado in class Empresa, what this means and what it serves?
class Funcionario {
String nome;
String cpf;
}
class Empresa {
String nome;
Funcionario empregado;
}
It’s called composition.
– user28595
What is the composition for?
– user50860
In the link there is a very quiet explanation about it, see if it clarifies you.
– user28595
Perhaps relevant: Composition and aggregation: what differences and how to use?
– Math
I’m not sure where your doubt lies, but at the most basic level,
Funcionariois the member’s typeempregadoexpected in instances ofEmpresa.– bfavaretto
@Thiagodebonis the answer helped you? You know you can accept an answer in your questions, right? Something needs to be improved for the answer to be accepted?
– Maniero