Question: Hi guys I hava Java task and Im looking for solution Need to write generic methods with this collection HashMap and TreeMap and then test

Hi guys

I hava Java task and Im looking for solution

Need to write generic methods with this collection HashMap and TreeMap and then test everything in RunnerClass

All methods need to be generic

For example all methods looks like this one below , I put two examples, one method with ArrayList and one with LinkedList:

-Method that will clear the given ArrayList:

public void clearList(ArrayList list) { list.clear();

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

-public void insertAtIndex(LinkedList list, int index, T element) { list.add(index, element);

An example of the above methods, please help me write generic method for HashMap and TreeMap

HashMap

1. Method that will return a shallow copy of the HashMap.

2. Method that will complete the HashMapa given as the first argument with elements from the HashMap given as the second argument

TreeMap

1. Method that will return the first key at least equal to or greater than the key passed in the argument (if such a key does not exist, it will return the next higher one);

2. Method that will return a SortedMap containing part of the TreeMapa where the keys are greater or equal to the key given as argument

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!