Question: I have the following method: /** * Read a line of text from standard input (the text terminal), * and return it as a set

I have the following method:

/** * Read a line of text from standard input (the text terminal), * and return it as a set of words. * * @return A set of Strings, where each String is one of the * words typed by the user */ public HashSet getInput() { System.out.print("> "); // print prompt String inputLine = reader.nextLine().trim().toLowerCase();

String[] wordArray = inputLine.split(" "); // split at spaces

// add words from array into hashset HashSet words = new HashSet<>(); for(String word : wordArray) { words.add(word); } return words; }

What I want to happen is just before the HashSet words is returned at the end of the statement, I want to iterate through the set and remove any common words. For example "the", "and", etc. How would I go about doing this?

Many thanks

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!