Question: Using java*** and use the code that has already been given below: Method Requirements: 1. The getNames method should work for any size array and
Using java***
and use the code that has already been given below:

Method Requirements: 1. The getNames method should work for any size array and work with any file regardless of the number of names in the file. 2. If the number of names in the file is less than or equal to the size of the array, the method should write all the name in the file to the array. 3. If the number of names in the file is greater than the size of the array, the method should fill the array with the names that appear at the top of the array (in the same order). 4. The getNames method cannot take any input (such as the number of names in the file) from user. 5. The method can contain only one loop. Simply, loop will read names one at a time from the file and store in the array. The loop should terminate either when the array is full, or end of file is reached. a import java.util.Scanner; import java.io.FileReader; import java.io.FileNotFoundException; public class Review1 { //The main method calls a method that throws FileNotFoundException //Therefore we have to declare it. public static void main(String[] args) throws FileNotFoundException { //creating a String array of size 7 String[] names = new String[7]; //call the getNames Method getNames ("list4.txt", names); print(names); } //print method public static void print(String() list) { //if a string is notstored in list[k], it contains null value I/We want to terminate the loop at first nul value. for(int k = 0; k
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
