Add a method called reportSet that accepts a list of Strings as its parameter and returns a new set containing only the unique words from the list. There are 32553 Unique words in the Mobydick file. Measure the time to add mobydick unique words to the set and compare the time adding them to the ArrayList (For this exercise, feel free to modify the starter main file QuizSet main) // start timer long startTime = System.currentTimeMillis (); // end timer long endTime System.currentTimeMillis ();
import java.io.*; import java.util.*; public class QuizSet { // Add reportset here // DO NOT MODIFY the code below public static void main (String [] args) { try{ //ArrayList ArrayList<String> words = new ArrayList<String>(); Scanner input = new Scanner (new File ("mobydick.txt")); while (input.hasNext()) { words.add(input.next()); } System.out.println (reportset(words).size()); } catch (FileNotFoundException e) { System.out.println (e); } } }
Add a method called reportSet that accepts a list of Strings as its parameter and returns a new set containing only the
-
answerhappygod
- Site Admin
- Posts: 899604
- Joined: Mon Aug 02, 2021 8:13 am
Add a method called reportSet that accepts a list of Strings as its parameter and returns a new set containing only the
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!