Question: Consider a text file of names, with one name per line, that has been compiled from several different sources. A sample is shown below: Brooke

Consider a text file of names, with one name per line, that has been compiled from several different sources. A sample is shown below:

Brooke Trout
Dinah Soars
Jed Dye
Brooke Trout
Jed Dye
Paige Turner

There are duplicate names in the file. We would like to generate an invitation list but don’t want to send multiple invitations to the same person. Write a program that eliminates the duplicate names by using a HashSet. Read each name from the file, add it to the HashSet, and then output all names in the HashSet to generate the invitation list without duplicates.

Step by Step Solution

3.49 Rating (159 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

public class InviteList public static void mainString args HashSet nameSet new HashSet S... View full answer

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 Java An Introduction to Problem Solving and Progra Questions!