Objects & Object References

Objects & Object References

Declaring objects:

Counter a = new Counter(0);

Counter b = new Counter(1);

Method invocation:

a.increment();

b.decrement();

Testing for equality:

a == b //simply tests if a and b reference the same object

a.equals(b) //tests object equality - using default Object method

Automatic garbage Collection:

a = b; //cause the object referenced by a to be garbage collected,

a = null; //there is no explicit deallocation of storage.

Previous slide Next slide Back to the first slide View Graphic Version