Question: java Given the partial code below, fill in the missing lines of code described by the commented sections. The program declares an ArrayList object of
java Given the partial code below, fill in the missing lines of code described by the commented sections. The program declares an ArrayList object of type String. Per the comments, write java statements to open a file named "StudentNames.txt add the names stored in the input file to the ArrayList object called sNameList. Write java statements to change all the names in the odd indices of the ArrayList object to the string Mr Sunday Movies". Run the completed program and paste a screenshot of the input file and the output.
write code to import the correct libraries
public class FinalExamQuestionArrayList
public static void mainString args add missing exception here
String fileName "StudentName.txt;
String studentName;
declare all file inputout ojects, and instantiate the file streams
add code here
ArrayList sNameList new ArrayList;
add code to read in all student names from a file and add to the
nameList object
System.out.printInitial list...
;
forint idx ; idx sNameList.size; idx
System.out.printlnStudent No idx :: sNameList.toString;
add code to change all the names in the odd indices of the
NameList object to the string Mr Sunday Movies"
System.out.print
Modified list...
;
forint idx ; idx sNameList.size; idx
System.out.printlnStudent No idx :: sNameList.toString;
write a java statement to close the input file
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
