Hi,
Thanks for your input but no it's not what I'm after... What you describe is roughly what I've got. And I use arraylists only because an airport can have more than one destination. The get(0) was just a sample in my code.
I do really need to have references to my airports in my arraylist no the actual values. Why? Because imagine this:
This would print out "Buffalo and Buffalo don't have as many destinations".
The scenario I imagined isn't far-fetched at all. Imagine I have some data representing airports, their names, their codes. I'm parsing that data to build Airport objects.
A holds destination B but has no knowledge of the latter's destinations as they are added later on to b. If I used references rather than values, it would work though.
In general how can I force
Java to make a copy by reference rather than value? In other words how can I get the address of my object? And how can I create a new object pointing to the same address?
And you could assume as well that by doing a.addDestination(b) it would add a to be too (although this is making the assumption that this is a bidirectional link which in airlines is a fairly safe but unnnecessary assumption)
Thanks a bunch.
[ April 07, 2007: Message edited by: David Brossard ]