![]() |
![]() |
![]() |
![]() |
![]() |
|
In the following definition of the
Demonstrate class, a Movie instance is created, values are
assigned to the instance variables, and the Movie instance's rating
is computed by a class method named movieRating. The
field-selection operator appears frequently:
public class Demonstrate {
public static void main (String argv[]) {
Movie m = new Movie();
m.script = 8; m.acting = 9; m.direction = 6;
System.out.print("The rating of the movie is ");
System.out.println(
Movie.movieRating(m.script, m.acting, m.direction)
);
}
}