public class mainTest {
public static void main(String[] args) throws Exception {
Scanner KB = new Scanner(System.in);
String VehiclesFile = "Vehicles.txt";
File file1 = new File(VehiclesFile);
Scanner infile1 = new Scanner(VehiclesFile);
Vehicle[] Vehicles = new Vehicle[0];
try {
Scanner scanner = new Scanner(file1);
int lineCount = 0;
while (scanner.hasNextLine()) {
lineCount++;
scanner.nextLine();
}
Vehicles = new Vehicle[lineCount];
scanner = new Scanner(file1);
int VehicleCount = 0;
while (scanner.hasNextLine()) {
String[] temp1 = scanner.nextLine().split(",");
// file has been read into temp1[] now to use Vehicles
// class type
Vehicles[VehicleCount] = new Vehicle();
Vehicles[VehicleCount].setregistration(temp1[0]);
Vehicles[VehicleCount].setmake(temp1[1]);
Vehicles[VehicleCount].setModel(temp1[2]);
Vehicles[VehicleCount].setyear(temp1[3]);
Vehicles[VehicleCount].setodometer(temp1[4]);
Vehicles[VehicleCount].setowner(temp1[5]);
VehicleCount++;
}
} catch (IOException e) {
// Print out the exception that occurred
System.out.println("Unable to find ");
}
//*******This is where I need to access the class to print****************
System.out.println (Vehicle.class.getClasses());
}
}
I cannot seem to understand how to reference a specific part of the class/array of class objects The class for Vehicle is in defined with get/set so I didn't include the code.