Question: have a text file named students.txt that has data like the below 412 18 male drumming 446 23 female running ... (keeps on going with

have a text file named students.txt that has data like the below


412 18 male drumming

446 23 female running

... (keeps on going with this structure 1.student number 2.age 3.gender 4. hobby)

How could I save this into an array (I know how to (do this) in arraylist but I want to know how to save each row into an array)


2nd question is if I (create this) array in a class named studentMain (which would be the main method) and wanted to use this array to update the instance variable values in another class named update, like private int studentNumber or private String gender which are originally set to 0 and "", how would I update that? (I thought I could do something like update info = new update(); and info.setStudentNumber()



Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

For the first question you can read each line from the file split it into separate pieces of data an... View full answer

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 Programming Questions!