Answered step by step
Verified Expert Solution
Question
1 Approved Answer
3.1 Implement the interface Map Define the interface Map. A class that realizes Map has to save the key value association. n our case we
3.1 Implement the interface Map Define the interface Map. A class that realizes Map has to save the key value association. n our case we need a Map to conta ndenti alkey in witih ase e method get, put, replace, and remove will refer to the association containing this key that is the further right (the last). Map is a generic class with two types of parameters, K and V where K is the type of the Key and V is the type of the values. A Map has the following methods: 1. V get(K key): Returns the rightmost value associated to the key specified in the parameter. 2. boolean contains(K key) Returns true if there is an association for the key specified in the parameter 3. void put(K key, V value): Creates a new key-value association 4. void replace(K key, V value): Replaces the value of the rightmost occurrence of the association for the specified key 5. V remove(K key): Removes the rightmost occurrence of the specified key and returns the value that was associated to this key Note that no parameter can be null in any of these methods public interface Map f /* Make the necessary abstract method definitions*/
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started