Question: You are required to build generic Map class using an ArrayList. A map consists a number of associations, each of which contains a unique key
You are required to build generic Map class using an ArrayList. A map consists a number of associations, each of which contains a unique key and a value that is associated with that key. It should support the following methods: // adds or replaces (if key exists) an association void put(T1 key, T2 val) // returns value given the key T2 get(T1 k) // prints the details of all associations in the map void print() // remove the value given the key, return true if the key is found, return false otherwise boolean get(T1 k) The Map class should allow any two classes to be associated (for example StudentID maps to Student etc). You may assume that the class used as Key implements Comparable, allowing comparison of two keys
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
