Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The Utilities class will contain two methods; removeDuplicates and linearSearch RemoveDuplicates public void removeDuplicates(final List items) Write a generic method that removes duplicate items from

The Utilities class will contain

two methods; removeDuplicates and linearSearch

RemoveDuplicates

public void removeDuplicates(final List items)

Write a generic method that removes duplicate items from the supplied List.

For example:

List strings = new ArrayList<>();

strings.add("one");

strings.add("two");

strings.add("one");

Utilities utilities = new Utilities();

utilities.removeDuplicates(strings);

The result is the list of strings contains two records; one and two.

List strings = new ArrayList<>();

strings.add("one");

strings.add("one");

strings.add("one");

Utilities utilities = new Utilities();

utilities.removeDuplicates(strings);

The result is the list of strings contains one record; one.

LinearSearch

Implement a generic method to do a linear search. Your linear search method should accept a

list containing a generic type, and a key record to search for in the generic list. Your search

should return the record associated with the supplied key or null if the key does not exist in the

supplied list.

public E linearSearch(List list, E key)

JUnit Tests

Write enough JUnit tests to achieve 100% test coverage and think carefully about your tests.

Along with showing that your generic methods work for different types of objects, i.e.

ArrayLists of Integers, Strings, FacebookUsers, etc., you should also test any unusual cases you

can think of:

What if the ArrayList is empty?

What if it contains only one item?

What if your removeDuplicates method is passed an ArrayList in which every item is

identical?

What if the arguments to the two methods are null?

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

Beginning PostgreSQL On The Cloud Simplifying Database As A Service On Cloud Platforms

Authors: Baji Shaik ,Avinash Vallarapu

1st Edition

1484234464, 978-1484234464

More Books

Students also viewed these Databases questions

Question

Does it use a maximum of two typefaces or fonts?

Answered: 1 week ago