So lets say i have a class Fruit and a Subclass called Apple. In the Fruit class is some kind of variable lets say a List of fruits or whatever. And i need that list of fruits in the apple class. So i know if i write extends Fruit on the Apple class then i get access to the fruit list from the super class (assuming the list is protected or public etc). So should i use inheritance to get the fruit list or should i use dependency injection to get the list somehow into the apple class? This question may be dumb but im a bit confused on this. I know that you can only extend from one class so if i needed two fruit lists or something else then i couldn't get the other one with inheritance. What i am doing right now in most classes is just from the main class im just getting the fruit list from the fruit class and then injecting it from there into all other classes that need it. Not sure if i inject the reference to the object or just the values there aswell.
So like when do i use dependency injection and when inheritance?