Home Segments Top Top Previous Next

214: Mainline

The following program uses both the zero-parameter constructor and the three-parameter constructor:

public class Demonstrate {
 // Define main:
 public static void main (String argv[]) {
  Movie m1 = new Movie();                       
  Movie m2 = new Movie(8, 9, 6);                
  System.out.println("The first movie rating is " + m1.rating()); 
  System.out.println("The second movie rating is " + m2.rating()); 
 } 
} 
--- Result --- 
The first movie rating is 15 
The second movie rating is 23