Reading txt file contents into parallel arrays code not working
// Create File Object
String fileName = "myfile.txt";
File file = new File(fileName);
Scanner scan = new Scanner(file);
int counter = 0;
String code = scan.next();
String moduleName = scan.next();
int totalPurchase = scan.nextInt();
moduleCodes[counter] = code;
moduleNames[counter] = moduleName;
numberOfStudents[counter] = totalPurchase;
The above code doesn't work.
When I try to print the first element of the first array like this:
it doesn't work, it just prints out Null.
Note: The code above for reading the file contents into arrays in inside a method.