[solved]-Create New Project Create Class Named Listpractice Project Paste Following Code Program Re Q39018935
Create a new project and create a class named ListPractice inthe project. Then paste in the following code:
/** * A program that reads Strings from two files into Lists, then displays a * “merged” list constructed from them in two different ways. * * */import java.util.ArrayList;import java.util.List;import java.util.Scanner;public class ListPractice { /** * Reads a list of words from a file – formatted one word per line – and * returns a List of those words in the order they appear in the file. If * there is an error reading the file, displays the error message “ERROR! * File wordsFile not found!” where “wordsFile” is the name of the file. If * there is an error reading the file, this method should return an empty * List. * * @param wordsFile * The name of a file in the proper format containg the word list * @return a List of words read from the file */ public static List<String> getList(String wordsFile) { // TODO – complete this function // TODO – the following line is only here to allow this program to // compile. Replace it and remove this comment when you complete // this method. return new ArrayList<String>(); } /** * Displays the contents of the list myList to the console. The list is * displayed with the index of the item, followed by a colon, then the item * with one item per line. * * @param myList * the List to be displayed */ private static void displayList(List<String> myList) { // TODO – complete this function } public static void main(String[] args) { Scanner keyboard = new Scanner(System.in); System.out.print(“Enter a filename: “); String fname = keyboard.nextLine(); List list1 = getList(fname); System.out.print(“Enter another: “); fname = keyboard.nextLine(); List list2 = getList(fname); System.out.println(“Wordlist 1”); System.out.println(“———-“); displayList(list1); System.out.println(); System.out.println(“Wordlist 2”); System.out.println(“———-“); displayList(list2); keyboard.close(); }}
Create a text file named “test1.txt” and paste the followinglines into it.
thequickbrownfoxjumps
And create a second text file named “test2.txt” and paste thefollowing line into it.
overthelazydog
Save Both files in the Project Folder.
Fill in these methods working with Lists – the main method hasalready been completed. The final project should produce outputlike the following:
Enter a filename: test1.txtEnter another: test2.txtWordlist 1———-0: the1: quick2: brown3: fox4: jumpsWordlist 2———-0: over1: the2: lazy3: dog
Expert Answer
Answer to Create a new project and create a class named ListPractice in the project. Then paste in the following code: /** * A pro… . . .
OR

