The file Names.txt is located in the folder input_files within your project. The content of that file is shown in the following figure Java: import java.io.FileInputStream; import java.io.FileNotFoundException; import java.util.ArrayList; import java.util.Scanner; public class Question2 { public static void main(String[] args) throws FileNotFoundException { /** * Part a * Finish creating an ArrayList called NameList that stores the names in the file Names.txt. */ ArrayList NameList; /** * Part b * Replace null on the right-hand-side of the declaration of the FileInputStream object named inputStream * so that it is initialized correctly to the Names.txt file located in the folder specified in the question description */ FileInputStream inputStream = null; Scanner scnr = new Scanner(inputStream); //Do not modify this line of code /** * Part c * Using a loop and the Scanner object provided, read the names from Names.txt * and store them in NameList created in Part a. */ /** * Part d * Reorder the names in the ArrayList so that they appear in reverse alphabetical order. */ // System.out.println("NameList after correct ordering: " + NameList); //Uncomment when you are ready to test Part d /** * Part e * Change the spelling of the name "Petor" to "Peter" in *NameList*. */ // System.out.println("NameList after corrected spelling: " + NameList); //Uncomment when you are ready to test Part e } }
The file Names.txt is located in the folder input_files within your project. The content of that file is shown in the following figure
Java:
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.Scanner;
public class Question2 {
public static void main(String[] args) throws FileNotFoundException {
/**
* Part a
* Finish creating an ArrayList called NameList that stores the names in the file Names.txt.
*/
ArrayList<String> NameList;
/**
* Part b
* Replace null on the right-hand-side of the declaration of the FileInputStream object named inputStream
* so that it is initialized correctly to the Names.txt file located in the folder specified in the question description
*/
FileInputStream inputStream = null;
Scanner scnr = new Scanner(inputStream); //Do not modify this line of code
/**
* Part c
* Using a loop and the Scanner object provided, read the names from Names.txt
* and store them in NameList created in Part a.
*/
/**
* Part d
* Reorder the names in the ArrayList so that they appear in reverse alphabetical order.
*/
// System.out.println("NameList after correct ordering: " + NameList); //Uncomment when you are ready to test Part d
/**
* Part e
* Change the spelling of the name "Petor" to "Peter" in *NameList*.
*/
// System.out.println("NameList after corrected spelling: " + NameList); //Uncomment when you are ready to test Part e
}
}
![Petor
Winston
Laura
Bonnie](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Feda77d24-879a-4257-ad32-00b1f0124616%2Fae7b7ed4-c45f-4f9f-872e-852f4339db0a%2Fo8hx6g9_processed.png&w=3840&q=75)
![](/static/compass_v2/shared-icons/check-mark.png)
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 2 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![C How to Program (8th Edition)](https://www.bartleby.com/isbn_cover_images/9780133976892/9780133976892_smallCoverImage.gif)
![Database Systems: Design, Implementation, & Manag…](https://www.bartleby.com/isbn_cover_images/9781337627900/9781337627900_smallCoverImage.gif)
![Programmable Logic Controllers](https://www.bartleby.com/isbn_cover_images/9780073373843/9780073373843_smallCoverImage.gif)