![]() |
![]() |
![]() |
![]() |
![]() |
|
Now, you can create a movie array in
main, and can hand that array to the readData class method,
defined in the Auxiliaries class. Evidently, the readData
method adds elements to the array and returns it, whereupon a for loop
displays ratings. Note that the main program determines that there
are no more movies with which to deal by looking for null, as explained in
Segment 522:
import java.io.*;
public class Demonstrate {
public static void main(String argv[]) throws IOException {
Movie mainArray [] = new Movie [100];
mainArray = Auxiliaries.readData(mainArray);
Movie m;
for (int counter = 0; (m = mainArray[counter]) != null; ++counter) {
System.out.println(m.rating());
}
}
}