Creation
and deletion of objects
The 憂ew?operator creates new objects
of a specific class.
An object is an instance of a class.
In Java we can create an object using the keyword new as follows:
new
String("Fred Smith");
new TextItem(
"Deitel & Deitel", 1041, "Dei 304.167");
new BouncingBall();
Such statements will result in a new object
being created ?a new instance of the specified class. When a new object
is created, an area of the computer's memory is allocated to store the
object.
Objects do not usually have to be explicitly
removed. A process called garbage collection is how the Java run-time
interpreter gets rid of them when they are no longer accessible.
Back
to top
RITSEC - Global Campus
Copyright © 1999 RITSEC- Middlesex
University. All rights reserved.
webmaster@globalcampus.com.eg
|