Search:

Type: Posts; User: meijuh

Search: Search took 0.85 seconds.

  1. Replies
    8
    Views
    2,412

    Re: ArrayList implementation

    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.
  2. Replies
    8
    Views
    2,412

    Re: ArrayList implementation

    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...
  3. Replies
    8
    Views
    2,412

    Re: ArrayList implementation

    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...
  4. Replies
    8
    Views
    2,412

    Re: ArrayList implementation

    Then how will the get method now whether to return an object of the type B or C?
  5. Replies
    8
    Views
    2,412

    ArrayList implementation

    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...
Results 1 to 5 of 5