![]() |
![]() |
![]() |
![]() |
![]() |
|
The following program creates an array that can hold up to 100 Movie
instances. Then, it fills part or all of that array with Movie
instances:
import java.io.*;
public class Demonstrate {
public static void main(String argv[]) throws IOException {
FileInputStream stream = new FileInputStream("input.data");
InputStreamReader reader = new InputStreamReader(stream);
StreamTokenizer tokens = new StreamTokenizer(reader);
int movieCounter = 0;
Movie movies [] = new Movie [100];
while (tokens.nextToken() != tokens.TT_EOF) {
int x = (int) tokens.nval;
tokens.nextToken(); int y = (int) tokens.nval;
tokens.nextToken(); int z = (int) tokens.nval;
movies [movieCounter] = new Movie(x, y, z);
++movieCounter;
}
stream.close();
}
}