Java Reference
In-Depth Information
er1.print();
er2.print();
er3.print();
produces this output:
New instance created for er1
New instance created for er2
New instance created for er3
obj=er1, name=Jack, id=123
obj=er2, name=Jack, id=123
obj=er3, name=Jack, id=123
Changing the
myName
external variable from “Jack” to “Jill” causes a bind recal-
culation on all three
EmpRec
objects, and in one case an object recreation. Exe-
cuting this code:
myName = "Jill";
er1.print();
er2.print();
er3.print();
yields the following:
New instance created for er1
obj=er1, name=Jill, id=123
obj=er2, name=Jill, id=123
obj=er3, name=Jill, id=123
Finally, changing the
myID
external variable from 123 to 456 results in a recalcu-
lation and object recreation on
er1
and
er3
. For
er2
, no changes take place at
all, because
er2
's
id
attribute is unbound. Running this code:
myID = 456;
er1.print();
er2.print();
er3.print();
outputs this:
New instance created for er1
New instance created for er3
obj=er1, name=Jill, id=456
obj=er2, name=Jill, id=123
obj=er3, name=Jill, id=456
Search WWH ::
Custom Search