I don’t know how you designed your models but you can follow this way:
class Person {
String name;
Integer age;
List<Address> addressList;
// getter, setter, const...
}
class Address {
// some fields...
// getter, setter, const...
}
And then you can add your address
to your person
via add
method:
Person p = new Person();
Address a = new Address();
// modiy person and address...
p.getAddressList().add(a);
solved How can I add one list to another list’s field? [closed]