Is there a way to subclass the ArrayList class to only allow objects of a specific class (or subclass thereof).
Specifically, I have a base class called RecordStatus and I need to create ArrayLists with objects based on this class.
I know it would be easy to create a class based on ArrayList<RecordStatus> but then, every time I retrieve an element from the array, I need to cast it to the original class.
Is there an easier way to do this?
Is there a way to subclass the ArrayList class to only allow objects of
Share
ArrayList<? extends RecordStatus>is as close as you can get.