Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Can someone please do this assignment for me ASAP thank you so much in advance. HashMap is a Map-based collection that is used to store

Can someone please do this assignment for me ASAP thank you so much in advance.

HashMap is a Map-based collection that is used to store key-value pairs HashMap. This class makes no guarantees as to the order of the map.

HashMap is similar to the Hashtable except that the latter is unsynchronized and permits nulls (null values and null keys).

HashMap is not an ordered collectionit does not return the keys and values in the same order as they have been inserted into HashMap, and it does not sort the stored keys and values. You need to import java.util.HashMap in order to use the HashMap class and its methods.

Before proceeding to coding, review the code samples linked below and see how to create a HashTable and/or a HashMap and use these structures for effective data storage and retrieval. Also review the Iterator class and its use to retrieve data structure content.

Submit the following program:

Explore the HashMapDemo code below and add the required elements specified in the comment lines:

import java.util.*; // clarify this import statement importing only the classes necessary for this particular application public class HashMapDemo { public static void main(String args[]) { HashMap countriesMap = new HashMap(); countriesMap.put( 1, USA); countriesMap.put( 2, Mexico); countriesMap.put( 5, France ); countriesMap.put( 21, India); countriesMap.put( 49, Australia); // continue adding 5 more key-value pairs // Display the content using Iterator. See the Iterators video in Week 5 media resources and a sample in the Doc Sharing area. // get and display the country based on the key value : accept the key value = 49 // remove Australia and Mexico from the countriesMap // determine and display how many countries are left in the HashMap // Display the content of modified countriesMap // remove all mapping entries from the countriesMap and display the resulting content of the HashMap } }

Save the completed code as HashMapDemo.java. Compile and run your application; debug errors if necessary.

Make your application user friendly and explain to potential users what they see (i.e., an initial countries list, the changes made, the modified list, etc.). Format the output in an orderly fashion for easy reading.

Create a UML class diagram of the application illustrating class hierarchy, collaboration, and the content of each class (include as a part of the MS .doc documentation below).

What are the differences between HashTable and HashMap classes?

Could one rather than the other have advantages to be implemented in Java applications?

What difference could be made for the HashMapDemo application if you were to utilize the HashTable class?

Step by Step Solution

There are 3 Steps involved in it

Step: 1

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

Database Concepts

Authors: David Kroenke, David Auer, Scott Vandenberg, Robert Yoder

10th Edition

0137916787, 978-0137916788

More Books

Students also viewed these Databases questions