I moved responsibility from the list to the B and C class. Now the list does not need to know whether the A is in fact a B or C. So this question is no longer relevant.
Thanks for your help Kevin.
Type: Posts; User: meijuh
I moved responsibility from the list to the B and C class. Now the list does not need to know whether the A is in fact a B or C. So this question is no longer relevant.
Thanks for your help Kevin.
When adding an element to the ArrayList I know that it is either a B or a C. Before actually adding it I need to check if that B or C is already contained by the ArrayList. So ArrayList.add() which I...
But this means I need to implement MyArrayList two times for exactly the same functionality. Is there no other way?
I believe type casting indicates a bad design...
Then how will the get method now whether to return an object of the type B or C?
Hi,
I need to do the following.
Suppose I have a class A and class B and C are subtypes of A.
I want to implement an ArrayList that contains subtypes of A. But I only want to implement this...