Re: a question about alias of reference
On 7/16/2010 3:52 PM, www wrote:
Sorry. Another related question:
Person tom = new Person("Tom");
Person tim = new Person("Tim");
tim.setAge(40);
List<Person> peopleList = new ArrayList<Person>();
peopleList.add(tom);
peopleList.add(tim);
for(Person p : peopleList)
{
if(p.getName().equalsIgnoreCase("Tom"))
{
p = null;
}
else if(p.getName().equalsIgnoreCase("Tim"))
{
p.setAge(30);
}
}
tim.getAge() is 40 or 30?
Write your address on a piece of yellow paper; call the paper
`tom'. Write your main squeeze's address on a piece of pink paper;
call the paper `tim'. With me so far? Yellow, pink, keep 'em
straight.
Copy what's written on the yellow paper onto a piece of white
paper called `p', then erase it. Copy what's on the pink paper to
`p', show it to the pizza guy, and say "Deliver a King Kong Killer
Kolesterol Kannonball (no anchovies) to this address." Where does
the pizza go? (Assume the pizza guy can read and remember ...)
--
Eric Sosman
esosman@ieee-dot-org.invalid