Basically I have my own List class that contains different fruits. Suppose each fruit has an identification number, which is stored in a list.
Better to have:
new AppleList(); new OrangeList(); new LemonList();
or
new FruitList<Fruit.Apple>(); new FruitList<Fruit.Orange>(); new FruitList<Fruit.Lemon>();
What to consider:
- All identifiers are of type int.
- The type of fetus does not affect the implementation of the List itself. It will be used only by the list client, as an external method, etc.
I would like to use the one that is clearer, better in design, faster, more efficient, etc. Also, if these 2 methods above are not the best, suggest your ideas.
EDIT: Btw Fruit is an enumeration if it's not clear.
Joan venge
source share