Home Segments Top Top Previous Next

545: Mainline

Curiously, the following pair of methods also works, although, at first glance, it might seem that nothing is returned from readData, inasmuch as readData has the void keyword, instead of a return type, and the call to readData does not appear in an assignment statement:

import java.io.*;
public class Demonstrate {
 public static void main(String argv[]) throws IOException {
  Movie mainArray [] = new Movie [100];
  Auxiliaries.readData(mainArray);                              
  // Remainder as in Segment 543 
 } 
} 

import java.io.*;
public class Auxiliaries {
 public static void readData(Movie movies []) throws IOException { 
  FileInputStream stream = new FileInputStream("input.data");  
  InputStreamReader reader = new InputStreamReader(stream); 
  StreamTokenizer tokens = new StreamTokenizer(reader); 
  int movieCounter = 0;  
  // While loop as in Segment 544 
  stream.close();  
  // Return statement deleted here 
 } 
}