The JavaTM Tutorial
Previous Page Lesson Contents Next Page Start of Tutorial > Start of Trail > Start of Lesson Search
Feedback Form

Trail: Learning the Java Language
Lesson: Classes and Inheritance

The Class Body

The class body contains all of the code that provides for the life cycle of the objects created from it: constructors for initializing new objects, declarations for the variables that provide the state of the class and its objects, methods to implement the behavior of the class and its objects, and in rare cases, a finalize method to provide for cleaning up an object after it has done its job.

Variables and methods collectively are called members.


Note:  Constructors are not methods. Nor are they members.

The Stack class defines one member variable in its body to contain its elements--the items Vector. It also defines one constructor--a no-argument constructor--and three methods: push, pop, and isEmpty.


Previous Page Lesson Contents Next Page Start of Tutorial > Start of Trail > Start of Lesson Search
Feedback Form

Copyright 1995-2002 Sun Microsystems, Inc. All rights reserved.