I have the following structure:
I have class A
with an ArrayList
. This lists elements that are objects from class B
. Objects in Class B's ArrayList
are if type class C
.
I want to add a method to class A
, so I could add an element (of specific index in ArrayList A
) to class B
's ArrayList
.
Something like this :
class A -> ArrayList A -> index 2-> B.add(some_element);
Is this directly possible, or must I first get an object from A
's array-list, and make changes and add it back?