Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hi please help with Java task Need to write generic methods with this collection ArrayList, LinkedList, HashSet,TreeSet and then test everything in RunnerClass. All methods

Hi please help with Java task

Need to write generic methods with this collection ArrayList, LinkedList, HashSet,TreeSet and then test everything in RunnerClass.

All methods need to be generic

For example all methods looks like this one, thats example :

public  void ensure(ArrayList list, int value){ list.ensureCapacity(value)

ArrayList:

1.Method that replaces the third element of the ArrayList passed in the argument with another element (also passed in the argument)

2.Method that will increase the size of a given ArrayList by the specified value.

3.Method that will trim the capacity of the ArrayList to the number of elements it currently has.

4.Method that will clear the given ArrayList.

LinkedList:

1.Method that inserts a given item into the selected LinkedList index.

2.Method that checks weather the given element exist in LinkedList.

3.Method that will check weather a given LinkedList is empty or not.

4.Method that will return a LinkedList, the method is to compare the elements of two LinkedLists - if two Linked Lists have all, e.g. 3 elements the same. Linked List The result list should look like this: [true, true, true]

HashSet:

1.Method that will compar two set and return a collection of only those items that are common to both sets.

2. Method that will compare two HashSet- method is supposed to return boolean.

TreeSet:

1.Method that will return and remove the last element of the TreeSet passed in the argument.

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_2

Step: 3

blur-text-image_3

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

More Books

Students also viewed these Databases questions