Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Produce ArrayMapList and it (implements the MapInterface.java) Here is everything that is needed. The goal is to use produce an array list map that implements

Produce ArrayMapList and it (implements the MapInterface.java)


Here is everything that is needed. The goal is to use produce an array list map that implements the map interface and works with the tester

import java.util.Collection; import java.util.Set; /** * @author: * */ public interface MapInterface { /** * If the given key is not already in the map, adds the * key-value pair to the map. Otherwise, updates the old * value of the existing key to the specified value. * @param key the key * @param value the value to be stored in the map with the key * @return null if the key was not already in the map, or * the old value associated with the key if the key was already in the map */ public V put(K key, V value); /** * Gets the value from the map that is associated with the given key * @param key the key * @return the value associated with the key, or null if the key is * not in the map */ public V get(K key); /** * Removes from the key-value pair associated with the specified key * @param key the key * @return the value associated with the key, or null if the key is * not in the map */ public V remove(K key); /** * Returns whether the map contains the key-value pair associated with * the specified key * @param key the key * @return true if the map contains a key-value pair with the specified * key, and false otherwise */ public boolean containsKey(K key); /** * Returns whether the map contains no elements * @return true if the map contains no key-value pairs, and false otherwise */ public boolean isEmpty(); /** * Removes all elements from the map */ public void clear(); /** * Gets the number of key-value pairs in the map * @return the number of key-value pairs in the map */ public int size(); /** * Gets a set of all keys in the map * @return */ public Set keySet(); /** * Gets a set of all values in the map * @return */ public Collection values(); }


Tester

public class Tester { public static void main(String[] args) { ArrayListMap alm = new ArrayListMap(); System.out.println(alm.put("Cindy", 1)); System.out.println(alm.put("Nina", 2)); System.out.println(alm.put("Morgan", 3)); System.out.println(alm.put("Michael", 4)); System.out.println(alm.size()); System.out.println(alm.containsKey("Morgan")); System.out.println(alm.containsKey("Jack")); System.out.println(alm.get("Michael")); System.out.println(alm.values()); System.out.println(alm.keySet()); System.out.println(alm.put("Michael", 6)); System.out.println(alm.get("Michael")); System.out.println(alm.remove("Michael")); System.out.println(alm.remove("Morgan")); System.out.println(alm.remove("Nina")); System.out.println(alm.remove("Cindy")); System.out.println(alm.size()); } }

Step by Step Solution

3.27 Rating (162 Votes )

There are 3 Steps involved in it

Step: 1

I see that you want to produce an ArrayListMap class that implements the MapInterfacejava interface and works with the Tester class An ArrayListMap is a type of map that uses an array list to store th... 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

Step: 3

blur-text-image

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

Understanding Business Ethics

Authors: Peter A. Stanwick, Sarah D. Stanwick

3rd Edition

1506303234, 9781506303239

More Books

Students also viewed these Programming questions