logo Practice-It logo


Language/Type: Java Collections Sets and Maps
Author: Marty Stepp (on 2021/04/02)

Write a method called deepCopy that takes as a parameter a map whose keys are strings and whose values are lists of integers and that creates and returns a new map that is a copy of the map parameter. For example, given a variable called map that stores the following information:

        {"cse143"=[42, 17, 42, 42], "goodbye"=[3, 10, -5],
         "hello"=[16, 8, 0, 0, 106]}

the call deepCopy(map) should return a new map whose structure and content are identical to map. Any later modifications to map or the lists in map following this call should not be reflected in the copy. The map you construct should store keys in alphabetical order. Your method should not modify the contents of the map passed as a parameter. In constructing collection objects, you are required to use the 0-argument constructors.

Type your solution here:

This is a method problem. Write a Java method as described. Do not write a complete program or class; just the method(s) above.

You must log in before you can solve this problem.

Log In

If you do not understand how to solve a problem or why your solution doesn't work, please contact your TA or instructor.
If something seems wrong with the site (errors, slow performance, incorrect problems/tests, etc.), please

Is there a problem? Contact a site administrator.