Skip to content
Advertisement

Scanning input in HashMap of String and ArrayList

I need to add all these cities in a HashMap of String and ArrayList

JavaScript

And I am unable to add these , I have the structure

JavaScript

So now i need to add banglore and then if banglore is present i will add Hyderabad to the ArrayList and again I’ll scan for the next element again banglore is present so add Chennai to the ArrayList.

There is already a question of creating a HashMap of String and ArrayList but firstly it is List of HashMap and Secondly no one there have shown how to add.

Advertisement

Answer

Try this.

JavaScript

output:

JavaScript
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement