您的位置:寻梦网首页编程乐园Java天地Core JavaJava Lecture Notes
Introduction
Content
Apply
Reflect
Extend
previous.gif
 (3087 bytes)
next.gif
 (2959 bytes)

 
 
Content Index
Content Page # 8

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

basicline.gif (169 bytes)

RITSEC - Global Campus
Copyright © 1999 RITSEC- Middlesex University. All rights reserved.
webmaster@globalcampus.com.eg