Question: Map has its implementation in various classes like HashMap. Following is an example to explain map functionality: import java.util.*; public class CollectionsDemo { public static

Map has its implementation in various classes like HashMap. Following is an example to explain map functionality:

import java.util.*; public class CollectionsDemo {

public static void main(String[] args) { Map m1 = new HashMap(); m1.put("Zara", "8"); m1.put("Mahnaz", "31"); m1.put("Ayan", "12"); m1.put("Daisy", "14");

System.out.println(); System.out.println(" Map Elements"); System.out.print("\t" + m1); } }

Implement atleast 6 methods (in Java) from the below table (screenshot) by using the given code and write down the output. Methods are described in screenshot.

Map has its implementation in various classes like HashMap. Following is an

Method Summary void clear () Removes all of the mappings from this map (optional operation) Returns true if this map contains a mapping for the specified key Returns true if this map maps one or more keys to the speci boolean containsKey (Object key boolean containsvalue (Object value) fied value entrySet () SetcMap Entry boolearn Returns a Set view of the mappings contained in this map Compares the specified object with this map for equality Returns the value to which the specified key is mapped, or equals (object o) get (Object key) nu1l if this map contains no mapping for the key hashCode () int Returns the hash code value for this map Returns true if this map contains no key-value mappings. Returns a Set view of the keys contained in this map. boolean i sEmpty Set keySet ( Method Summary (continued) put (K key, V value) Associates the specified value with the specified key in this map (optional operation) void putAll (Mapvalues () Returns a Collection view of the values contained in this map

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!