![]() |
![]() |
![]() |
![]() |
![]() |
|
The following is a Java definition of the Movie class in which
instance variables are declared; evidently, the chunks of memory that
describe movies hold values for three integers: script, acting,
and direction:
public class Movie {
// First, define instance variables:
public int script, acting, direction;
// Remainder of class definition
}
This definition indicates, via the absence of the static
keyword, that the variables are instance variables, rather than class
variables.
Furthermore, the definition of the Movie class indicates, via the
public keyword, that all the instance variables describing a
Movie instance will be available, and changeable, from anywhere in
your program. You learn about other kinds of instance variables in
Chapter 15.