I’ve have an Object Accounts which has sub Accounts within it.
I both have the same structure I need there to be one parent account with 1 to many children associated with. They are both going to be mapped to the same object class (which I cannot edit, always the way!) on different objects. So Is it possible to have an array of the Object within the actual object itself. Or should I make a List of the parent and within that list have a list of children?
EDIT: I cannot edit the class.
I am currently working like this:
Account acc = new Account()
Account[] subacc = new Account[length]
Now this is the question. Without editing Account How can I associate Parent and children. I assume the only way is to create a wrapper object to hold both of them? Is there a cleaner way to do this?
You mean something like this?
Absolutely. (And the same is true for a
List<Account>, or just a singleAccountfield etc.)