In practice, if it is as clear as in Java and there are no pointers in Java. Only references. A reference is (roughly) equals to a pointer. For someone who comes from C, I would say that we must see to simplify the Java language as a pointer while (except that there is no need to manage the release because the garbage collector takes care of everything). This means that there is no principle of local object.
For example:
Code:
MyObject obj;
MyObject obj2;
Do not instantiate this object code as in C. And if we
Code:
MyObject obj;
MyObject obj2;
obj = new MyObject ();
obj2 = obj;
References all point to the two same instance. For proof, simply display a trace in the constructor.
Bookmarks