Question: please solve using explanation The following code creates a Hashmap called people which stores key/age pairs. It makes a separate map for children (less than

please solve using explanation
please solve using explanation The following code creates a Hashmap called people
which stores key/age pairs. It makes a separate map for children (less

The following code creates a Hashmap called people which stores key/age pairs. It makes a separate map for children (less than 18 years old) and prints them in order by age. The strategy is to go through each of the key/age pairs, check if age less than 18 to add that information to a new "child map" and remove it from people map. Finally, it goes through this child map in order by age and produces the desired output. Complete the five missing lines as indicated in the numbered comments. lic class JavaApplication II 1. Declare children map to be used for (String key : people.keyset()) 1 /I 2. Retrieve age corresponding to this person II 3. if a child, add it to children map if ( aget 1/ create a Hashmap object called people HashMapsstring, Integer > people = new HashMap (); 11 add keys and values (Name, Age) people, put ("John", 2); people,put ("Steve", 30); people.put ("Angie", 3); HashMapestring, Integer> children = ExtractChildren (people): 11 5. Create a sorted version of the children map called sortedChildren for (String I : sortedchildren, keyset ()) System.out.println ("key: "+ + + " value: "+ sortedchildren,get(i))

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!