Let's say I have a Person class and an Address class. Assume that one person can have multiple addresses. I am thinking that I would put an array or a collection variable on the person and then populate it with Address objects. Is this the generally accepted way of doing it or is there something I am missing?
FYI - I am tyring to create a very simple Rolodex type program just to teach myself some Java skills.
posted 11 years ago
Sure, you could do that. A class data member can be another class. I'd consider using a scalable array, such as ArrayList, but there is some additional overhead. For a Rolodex type of progam, the overhead wouldn't really matter much unless your targeting portable devices like Palm or CE.
Give a man a fish, he'll eat for one day. Teach a man to fish, he'll drink all your beer.
Cheers, Jeff (SCJP 1.4, SCJD in progress, if you can call that progress...)