Question: In java, i have a text file , I read the information from the text file and set them to variables, my program has a

In java, i have a text file , I read the information from the text file and set them to variables, my program has a bunch of classes with getters and setters but i want to create an array for 3 different types of the classes and use the setters from those three classes and have different objects because the text files have different lines of information that each line needs to be stored in a different part of the array, im not sure if im saying this properly but please help with some code

String theLine =input.nextLine();

String[] fields = theLine.split(",");

String staffType = fields[0];

String firstName = fields[1];

String lastName = fields[2];

int staffId = Integer.parseInt(fields[3]);

int department = Integer.parseInt(fields[4]);

int month = Integer.parseInt(fields[5]);

int day = Integer.parseInt(fields[6]);

int year = Integer.parseInt(fields[7]);

String gender = fields[8];

String phoneNum = fields[9];

String email = fields[10];

this is how i stored them but now i want to set them using setters from another class

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!