Reputation: 77
Is it correct to use an already implemented Collection (like a ArrayList) to implement my custom collection? Or could be there any problem?
Something like this:
public class customCollection<E> implements Collection <E> {
List<E> objects = new ArrayList<E>();
}
Upvotes: 1
Views: 69
Reputation: 503
That is absolutely OK. I have specialised data classes (that also have some business logic) that implement one standard type and have internally various objects for other reasons.
Take care to not produce unmaintainable code. For this, you could use tools such as SonarQube. Check, when you rely on (many) classes, how much do you use - in other words, how dependent is your class froom other interfaces, classes, inherited methods? See, for example http://tutorials.jenkov.com/ood/understanding-dependencies.html
Upvotes: 2