Hi Martin,
as Bu mentions, the k variable is an instance variable which means
it follows the object throughout the objects lifetime and can be
accessed everywhere in the object.
i on the other hand only lives within the setPrice method. When you return
from the method the i variable will "die" and can be collected by the
garbage collector.
edit:
if you, on the other hand, means: what's the difference between i and k
in the following example:
within the method there's no difference between the two variables, however
i is already initialized (ie. it has a value) when it enters the method -
this however might not be true if i was an object and not a simple type
(e.g. public void
test(MyObject i) could have been invoked with test(null))
[ September 28, 2006: Message edited by: Svend Rost ]