Now, there is dependency between Employee and Address because Employee is forced to use the same address instance.
Let's write the IOC or DI code.
publicclass Employee{
Address address;
Employee(Address address){
this.address=address;//not creating instance
}
}
Now, there is no dependency between Employee and Address because Employee is not forced to use the same address instance. It can use any address instance.
Disclimer: PCDS.CO.IN not responsible for any content, information, data or any feature of website.
If you are using this website then its your own responsibility to understand the content of the website