Answered step by step
Verified Expert Solution
Question
1 Approved Answer
import java.io . BufferedReader; import java.io . FileReader; import java.io . IOException; import java.util.ArrayList; public class FinalExam _ QuestionArrayList { public static void main (
import java.ioBufferedReader;
import java.ioFileReader;
import java.ioIOException;
import java.util.ArrayList;
public class FinalExamQuestionArrayList
public static void mainString args
String fileName "StudentNames.txt;
String studentName;
declare all file inputout objects, and instantiate the file streams
try FileReader fileReader new FileReaderfileName;
BufferedReader bufferedReader new BufferedReaderfileReader
ArrayList sNameList new ArrayList;
add code to read in all student names from a file and add to the nameList object
while studentName bufferedReader.readLine null
sNameList.addstudentName;
System.out.printInitial list...
;
for int idx ; idx sNameList.size; idx
System.out.printlnStudent No idx :: sNameList.getidx;
add code to change all the names in the odd indices of the
NameList object to the string Mr Sunday Movies"
for int idx ; idx sNameList.size; idx
sNameList.setidxMr Sunday Movies";
System.out.print
Modified list...
;
for int idx ; idx sNameList.size; idx
System.out.printlnStudent No idx :: sNameList.getidx;
catch IOException e
eprintStackTrace;
write a java statement to close the input file none needed as trywithresources is used
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started