How to read a 2d array from a file in java?
Answers
UR ANSWER
1.Instantiate Scanner or other relevant class to read data from a file.
Instantiate Scanner or other relevant class to read data from a file.2. Create an array to store the contents.
Instantiate Scanner or other relevant class to read data from a file.2. Create an array to store the contents.To copy contents, you need two loops one nested within the other. the outer loop is to traverse through the array of one dimensional arrays and, the inner loop is to traverse through the elements of a particular one dimensional array.
Instantiate Scanner or other relevant class to read data from a file.2. Create an array to store the contents.To copy contents, you need two loops one nested within the other. the outer loop is to traverse through the array of one dimensional arrays and, the inner loop is to traverse through the elements of a particular one dimensional array.3.Create an outer loop starting from 0 up to the length of the array. Within this loop read each line trim and split it using nextLine(), trim(), and split() methods respectively.
Instantiate Scanner or other relevant class to read data from a file.2. Create an array to store the contents.To copy contents, you need two loops one nested within the other. the outer loop is to traverse through the array of one dimensional arrays and, the inner loop is to traverse through the elements of a particular one dimensional array.3.Create an outer loop starting from 0 up to the length of the array. Within this loop read each line trim and split it using nextLine(), trim(), and split() methods respectively.Create the second loop starting from 0 up to the length of the line. Within this loop convert each element of the string array to integer and assign to the array created in the previous step.