Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

The Manga Guide To Databases

Authors: Mana Takahashi, Shoko Azuma, Co Ltd Trend

1st Edition

1593271905, 978-1593271909

More Books

Students also viewed these Databases questions